vars <- c("mpg","hp","wt")
dstats <-function(x)(c(mean=mean(x),sd=sd(x)))
by(mtcars[vars],mtcars$am,dstats)
----------------------------------------------------------------------------------------------------------------------------
> vars <- c("mpg","hp","wt")
> dstats <-function(x)(c(mean=mean(x),sd=sd(x)))
> by(mtcars[vars],mtcars$am,dstats)
Error in is.data.frame(x) :
'list' object cannot be coerced to type 'double'
此外: Warning message:
In mean.default(x) : 参数不是数值也不是逻辑值:回覆NA
Called from: is.data.frame(x)