我已经在列表下面的示例数据称为data
R:拆分列表中列和转化为新的data.frames
data <- structure(list(`1.1` = structure(list(id = structure(1, .Dim = c(1L,
1L)), Sample = structure("Test1", .Dim = c(1L, 1L)), Add = structure("T", .Dim = c(1L,
1L))), .Names = c("id", "Sample", "Add")), `2.1` = structure(list(
id = structure(5, .Dim = c(1L, 1L)), Sample = structure("Test2", .Dim = c(1L,
1L)), Add = structure("A", .Dim = c(1L, 1L))), .Names = c("id",
"Sample", "Add")), `3.1` = structure(list(id = structure(7, .Dim = c(1L,
1L)), Sample = structure("Test3", .Dim = c(1L, 1L)), Add = structure("D", .Dim = c(1L,
1L))), .Names = c("id", "Sample", "Add")), `4.1` = structure(list(
id = structure(12, .Dim = c(1L, 1L)), Sample = structure("Test4", .Dim = c(1L,
1L)), Add = structure("Z", .Dim = c(1L, 1L))), .Names = c("id",
"Sample", "Add")), `5.1` = structure(list(id = structure(17, .Dim = c(1L,
1L)), Sample = structure("Test12", .Dim = c(1L, 1L)), Add = structure("E", .Dim = c(1L,
1L))), .Names = c("id", "Sample", "Add"))), .Names = c("1.1",
"2.1", "3.1", "4.1", "5.1"), row.names = c("id", "Sample", "Add"
), class = "data.frame")
它看起来像这样:
data
1.1 2.1 3.1 4.1 5.1
id 1 5 7 12 17
Sample Test1 Test2 Test3 Test4 Test12
Add T A D Z E
我怎么可能分裂这个列表按列分成几个基于ID号码的数据帧?例如。一个名为data.ID1的data.frame和一个名为data.ID5的data.frame和一个名称为data.ID 7的data.frame被创建(参见下面的示例)? data.frame的名称应该与ID号相同。我的列表包含约700种不同的ID和数据...
data.ID1
id 1
Sample Test1
Add T
data.ID5
id 5
Sample Test2
Add A
data.ID7
id 7
Sample Test3
Add D
等等...
是ID值独特之处? – digEmAll
是的,它们是独一无二的。 – nebuloso
看着你想要的输出看起来,你想保持相同的格式(即ID,样本,添加为row.names)...我是否正确或你想把它们变成列名? – digEmAll