【发布时间】:2020-12-16 11:27:03
【问题描述】:
df=data.frame(Name=c("leonard","andrey","richard","john"), #initial data
Func=c("FUNC1","FUNC2","FUNC3","FUNC1"))
df=split(df,df$Func) # split by Func column
sapply(df,function(x){length(df$x)}) # error here attempt 1
sapply(df,function(x){nrow(df$x)}) # error attempt 2 give NULL result
我想知道此列表中每个 data.frame 中存在的观察数
预期输出:
> data.frame(FUNC1=2,FUNC2=1,FUNC3=1)
func1 func2 func3
2 1 1
【问题讨论】:
-
你可以使用
table()的输出
标签: r