这是我的数据框:
我想提取col1 =
换句话说,我的数据框应该具有3列,即每个条目的第一列。
dplyr包可以帮助我做到这一点吗?
需要帮忙吗?
df<-list(structure(list(Col1 = structure(1:6, .Label = c("A", "B",
"C", "D", "E", "F"), class = "factor"), Col2 = structure(c(1L,
2L, 3L, 2L, 4L, 5L), .Label = c("B", "C", "D", "F", "G"), class = "factor")), class = "data.frame", row.names = c(NA,
-6L)), structure(list(Col1 = structure(c(1L, 4L, 5L, 6L, 2L,
3L), .Label = c("A", "E", "H", "M", "N", "P"), class = "factor"),
Col2 = structure(c(1L, 2L, 3L, 2L, 4L, 5L), .Label = c("B",
"C", "D", "F", "G"), class = "factor")), class = "data.frame", row.names = c(NA,
-6L)), structure(list(Col1 = structure(c(1L, 4L, 6L, 5L, 2L,
3L), .Label = c("A", "W", "H", "M", "T", "U"), class = "factor"),
Col2 = structure(c(1L, 2L, 3L, 2L, 4L, 5L), .Label = c("B",
"C", "D", "S", "G"), class = "factor")), class = "data.frame", row.names = c(NA,
-6L)))
我想提取col1 =
df [[1]] [1]
作为一个数据框。 然后,我想将此列表的第二个位置的col1合并到df [[1]] [1]
,然后我将拥有一个具有2列的数据帧。
之后,我想将列表第三个位置的列1合并到具有两列的数据帧中,然后我将拥有一个具有3列的数据帧。换句话说,我的数据框应该具有3列,即每个条目的第一列。
dplyr包可以帮助我做到这一点吗?
需要帮忙吗?