错误:找不到功能“单位” [英] Error: could not find function "unit"
问题描述
在尝试修改主题设置时,此简单代码会给出以下错误:
library(ggplot2)
theme_nogrid < - theme_set(theme_update(
plot.margin = unit(c(.25,.25,.25,.25),in),))
do .call(theme,list(...)):找不到函数unit
R
给我这个错误的任何元素使用'单位'。任何其他不会调用'unit'的设置都可以正常工作。我正在运行R v.2.15.2(64位Windows)。
我在网上广泛搜索了关于这个问题,但什么都没发现。
我很感激这个问题的任何建议。
这与密切相关,尽管不完全相同,不再支持ggplot2中的箭头(),它表示:
$ ggplot2中的箭头()不再支持b$ b
[
grid [package]是由以前版本的 ggplot [2]
(使
grid
函数对用户可见/可访问);现在它通过NAMESPACE
导入引用
,所以如果$ b $需要显式加载grid
b要使用grid
函数(或[查看他们的帮助页面])。
显式加载在这里意味着 library(grid)
或 require(grid)
( grid
是一个基础包,因此不需要单独安装)。
unit()
是来自网格
包,所以上面的答案(这是关于 arrow()
)适用。
或者,您可以指定 grid :: unit(...)
或 grid: :arrow(...)
而不显式加载整个软件包。
While trying to modify theme settings this simple code gives the following error:
library(ggplot2)
theme_nogrid <- theme_set(theme_update(
plot.margin=unit(c(.25, .25, .25, .25), "in"),))
Error in do.call(theme, list(...)) : could not find function "unit"
R
gives me this error for any element that uses 'unit'. Any other settings that do not call 'unit' work fine. I am running R v.2.15.2 (64-bit Windows).
I extensively searched online about this problem and found nothing. I appreciate any suggestions to the problem.
This is closely related to, although not exactly identical to, arrow() in ggplot2 no longer supported , which says:
[the]
grid
[package] was loaded automatically by previous versions ofggplot[2]
(makinggrid
functions visible/accessible to the user); now it's referred to viaNAMESPACE
imports instead, so you need to explicitly loadgrid
if you want to usegrid
functions (or [to] look at their help pages).
"explicitly load" here means library("grid")
or require("grid")
(grid
is a base package, so doesn't need to be installed separately).
unit()
is a function from the grid
package, so the answer above (which was about arrow()
) applies.
Alternatively you can specify grid::unit(...)
or grid::arrow(...)
without explicitly loading the entire package.
这篇关于错误:找不到功能“单位”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!