我有一个数据框:
head(df)
Year Find Found
6982 1901 267 246
6983 1901 271 251
6984 1902 317 236
6985 1903 339 244
6986 1904 339 260
6987 1903 345 15
5255 1902 47 45
5256 1901 46 NA
5257 1906 45 150
5258 1905 42 24
5259 1910 42 78
5260 1910 41 NA
当我试图聚合它时:
aggdata <-aggregate(df, by=list(Year),
FUN=sum, na.rm=TRUE)
我得到一个error
Error in aggregate.data.frame(AndelKvinnorUttax, by = list(Year), FUN = sum, :
object 'Year' not found
我找不到问题...
我solution
的是:
aggr=cbind(aggregate(data=df,Find~Year,
FUN=sum,na.rm=TRUE),aggregate(data=df,Found~Year,
FUN=sum,na.rm=TRUE))[,c(1,2,4)]
任何人?
此致!