我不明白为什么我这么小的包装函数会产生主题错误.下面应该重现它.我的目标是从单个数据帧中的数据中做一堆图,每个图都位于一个新窗口中.
library(ggplot2)
library(datasets)
data(ChickWeight)
str(ChickWeight)
# This works fine:
qplot(x = weight, y = Time, data = ChickWeight, color = Diet)
myfun <- function(pred = weight, resp = Time, dat = ChickWeight) {
windows()
qplot(x = pred, y = resp, data = dat, color = Diet)
}
# But this returns 'Error in eval(expr, envir, enclos) : object 'weight' not found':
myfun()
# As does this
myfun(weight, Time)
Run Code Online (Sandbox Code Playgroud)
为什么R不能在我的功能中找到'重量'?
我在Windows 8.1 64位上运行R版本3.0.1,64位.
谢谢!
-Roy