【发布时间】:2021-10-04 21:11:28
【问题描述】:
我有 2 个表格对象,例如:
type1:
0 1 2 3 12 20
1318 841 4 1 1 1
type1<- structure(c(`0` = 1318L, `1` = 841L, `2` = 4L, `3` = 1L, `12` = 1L,
`20` = 1L), .Dim = 6L, .Dimnames = structure(list(c("0", "1",
"2", "3", "12", "20")), .Names = ""), class = "table")
和
type2:
0 1 2 12 15
93 178 1 4 1
type2<-structure(c(`0` = 93L, `1` = 178L, `2` = 1L, `12` = 4L, `15` = 1L
), .Dim = 5L, .Dimnames = structure(list(c("0", "1", "2", "12",
"15")), .Names = ""), class = "table")
我想合并它们以获得数据框,例如:
x y2 y
1 type1 841
2 type1 4
3 type1 1
4 type1 0
5+ type1 2
1 type2 178
2 type2 1
3 type2 0
4 type2 0
5+ type2 5
我将 type1 或 type2 >= 5 中的所有列相加,并将此计数添加到 5+ 行中。
请问有人有什么想法吗?
【问题讨论】: