99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2018-11-09 閱讀量: 941
R中關(guān)于by的一個問題
> 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'
In addition: Warning message:
In mean.default(x) : argument is not numeric or logical: returning NA
我看R語言實戰(zhàn)上面也這么寫的。能運行出結(jié)果,后來翻閱書籍幫我解決了這個,參考如下:

mean()函數(shù)只支持向量,不支持數(shù)據(jù)框輸入。所以自定義函數(shù)dstats也不支持數(shù)據(jù)框輸入。
解決辦法是將dstats改成如下,就可以了:dstats <- function(x) c(mean=sapply(x,mean), sd=sapply(x,sd))是sd=sapply(x,sd)

0.0000
3
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子