我试图弄清楚为什么我在使用ddply时收到错误消息.
示例数据:
data<-data.frame(area=rep(c("VA","OC","ES"),each=4),
sex=rep(c("Male","Female"),each=2,times=3),
year=rep(c(2009,2010),times=6),
bin=c(110,120,125,125,110,130,125,80,90,90,80,140),
shell_length=c(.4,4,1,2,.2,5,.4,4,.8,4,.3,4))
bin7<-ddply(data, .(area,year,sex,bin), summarize,n_bin=length(shell_length))
Run Code Online (Sandbox Code Playgroud)
错误消息:.fun(piece,...)出错:缺少参数"by",没有默认值
我昨天收到此错误消息.我重新启动R并重新编写代码,一切都很好.今天早上我再次收到错误消息并重新启动R并没有解决问题.
我还尝试运行一些示例代码并得到相同的错误消息.
# Summarize a dataset by two variables
require(plyr)
dfx <- data.frame(
group = c(rep('A', 8), rep('B', 15), rep('C', 6)),
sex = sample(c("M", "F"), size = 29, replace = TRUE),
age = runif(n = 29, min = 18, max = 54)
)
# Note the use of the '.' function to allow
# group and sex to be used without quoting
ddply(dfx, .(group, sex), summarize,
mean …Run Code Online (Sandbox Code Playgroud)