看看这个“简单”的功能:
test <- function(x,...){
UseMethod("test",x)
}
test.default<-function(x,y,data){
message("default")
print(deparse(substitute(x)))
print(deparse(substitute(y)))
print(deparse(substitute(data)))
print(match.call())
}
test.formula <- function(x,...){
message("formula")
print(deparse(substitute(x)))
print(match.call())
}
一切都很好
data(iris)
test.formula(Sepal.Length~Petal.Width,iris)
test.default(Sepal.Length,Petal.Width,iris)
test(Sepal.Length~Petal.Width,iris)
除了这个:
test(Sepal.Length,Petal.Width,iris)
由于 NSE :object 'Sepal.Length' not found
任何想法 ?