我知道代码中的含义tapply(dat$sale,list(dat$year,dat$province),sum)
:
> dat=data.frame(
+ year=c(rep(2007,5),rep(2008,3),rep(2009,3)),
+ province=c("a","a","b","c","d","a","c","d","b","c","d"),
+ sale=1:11)
> tapply(dat$sale,list(dat$year,dat$province),sum)
a b c d
2007 3 3 4 5
2008 6 NA 7 8
2009 NA 9 10 11
tapply(dat$sale,list(dat$year,dat$province))
如果里面没有FUN是什么意思?
> tapply(dat$sale,list(dat$year,dat$province))
[1] 1 1 4 7 10 2 8 11 6 9 12
它是一个下标,结果是什么意思12
?
我可以在哪个规则中获得或?如何计算它?9
12
9