[英]Join table() together in R
So ive been stuck with a problem in order to show the frecuencies of my groups across some data where i have multiple NA's.所以我遇到了一个问题,以便在我有多个 NA 的一些数据中显示我的组的频率。
Here its an example, i have dropped the Na's with the function drop_na, so they are "irrelevant" if i already got the tables.这是一个例子,我已经用 function drop_na 删除了 Na,所以如果我已经拿到了表格,它们是“无关紧要的”。
df_1= data.frame(Group=c("Control","Control","Case A","Case B", "Case C"), c(1,2,3,4,5))
table(df_1$Group)
df_2= data.frame(Group=c("Control","Case A","Case A","Case B", "Case D"), c(1,2,3,4,5))
table(df_2$Group)
How could i join them in 1?, preferably with a column indicating its origin as "table1" or something.我怎样才能将它们加入 1?,最好用一列指示其来源为“table1”或其他东西。
Like this?像这样?
tab <- rbind(table(df_1$Group),table(df_2$Group))
rownames(tab) <- c("table 1", "table 2")
tab
Case A Case B Case C Control
table 1 1 1 1 2
table 2 2 1 1 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.