R 访问列表中包含的公共元素数据帧
我有以下数据集:R 访问列表中包含的公共元素数据帧,r,R,我有以下数据集: id1 <- data.frame(level = c(1, 2, 3), time = c(45, 50, 60), location = c(124235,2352353,645664)) id2 <- data.frame(level = c(1, 2, 3), time = c(45, 50, 60), locat
id1 <- data.frame(level = c(1, 2, 3),
time = c(45, 50, 60),
location = c(124235,2352353,645664))
id2 <- data.frame(level = c(1, 2, 3),
time = c(45, 50, 60),
location = c(124235,2352353,645664))
id3 <- data.frame(level = c(1, 2, 3),
time = c(45, 50, 60),
location = c(124235,2352353,645664))
big.list <- list(id1,id2,id3)
id1您可以使用dplyr
包中的bind_行
dplyr::bind_rows(big.list,.id="id")
您可以使用dplyr
包中的bind_行
dplyr::bind_rows(big.list,.id="id")
带有rbindlist
fromdata.table
library(data.table)
rbindlist(big.list, idcol = 'id')
# id level time location
#1: 1 1 45 124235
#2: 1 2 50 2352353
#3: 1 3 60 645664
#4: 2 1 45 124235
#5: 2 2 50 2352353
#6: 2 3 60 645664
#7: 3 1 45 124235
#8: 3 2 50 2352353
#9: 3 3 60 645664
带有rbindlist
fromdata.table
library(data.table)
rbindlist(big.list, idcol = 'id')
# id level time location
#1: 1 1 45 124235
#2: 1 2 50 2352353
#3: 1 3 60 645664
#4: 2 1 45 124235
#5: 2 2 50 2352353
#6: 2 3 60 645664
#7: 3 1 45 124235
#8: 3 2 50 2352353
#9: 3 3 60 645664
这就是我想要的,但是否也可以在同一步骤中删除位置?执行library(dplyr);绑定行(big.list,.id=“id”)%%>%select(-location)
这是我想要的,但是也可以在同一步骤中删除位置吗?执行库(dplyr);绑定行(big.list,.id=“id”)%%>%select(-location)