私の非常に最小限のラッパー関数がサブジェクトエラーを生成する理由がわかりません。以下はそれを再現するはずです。私の目標は、それぞれが新しいウィンドウにある単一のデータフレーム内のデータから一連のプロットを作成することです。
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)
関数でRが「重み」を見つけられないのはなぜですか?
Windows 8.1 64ビットでRバージョン3.0.1、64ビットを実行しています。
ありがとう!
-ロイ