Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我用以下代码制作了两个表:
load(url("http://bit.ly/dasi_gss_data")) pres<-table(gss$year,gss$confed) emp<-table(gss$year,gss$joblose)
我现在正在尝试合并这两个表并保留年份大于 1987 的所有行和列。我尝试了合并功能,但一直出错。有什么建议么?我想将两个表中的所有列按年份分组。谢谢!
最终先做
df.pres <- as.data.frame(unclass(pres)) df.emp <- as.data.frame(unclass(emp))
然后重命名列,合并()和子集()
你想要这样的东西:
library(dplyr) gss %>% group_by(year, confed, joblose) %>% summarize(n = n())