答案 0 :(得分:1)
这是一个解决方案。
# the data
dat <- data.frame(X = c("Program Manager", "Program Coordinator",
"Senior Manager", "Senior Associate",
"Senior Researcher"),
stringsAsFactors = FALSE)
# count words
table(unlist(strsplit(dat$X, " +")))
结果:
Associate Coordinator Manager Program Researcher Senior
1 1 2 2 1 3
使用as.data.frame
,结果可以转换为数据框。
tab <- table(unlist(strsplit(dat$X, " +")))
as.data.frame(tab)
结果:
Var1 Freq
1 Associate 1
2 Coordinator 1
3 Manager 2
4 Program 2
5 Researcher 1
6 Senior 3