以下是head
我的数据:
dput(head(trucksv[,c(1,5)]))
structure(list(Measur. = c(1L, 2L, 3L, 4L, 5L, 1L), Speed.Mean.Trucks = c(NA,
NA, 9.5, 4.5, NA, NA)), .Names = c("Measur.", "Speed.Mean.Trucks"
), row.names = c(1L, 2L, 3L, 4L, 5L, 17L), class = "data.frame")
我想通过“测量”找到速度的累积分布。为此我使用了以下功能:
f <- function(x) {
hi <- hist(x)
speedmph=round(hi$breaks*0.68,1)
prob=c(0, round(cumsum(hi$counts)/sum(hi$counts),digits=2))
cbind(speedmph, prob)
}
但是当我尝试将它应用于我的数据时,R 给了我以下错误:
tspdistu <- ddply(trucksv, 'Measur.', summarise, trucksspeedmph = f(Speed.Mean.Trucks))
Error in hist.default(x) : invalid number of 'breaks'
Called from: top level
Browse[1]>
我不确定如何找到正确数量的垃圾箱。请帮忙。提前致谢。