this question的后续工作:我有一个名为G
的数据帧列表。
在BASE R中,我想知道如何分别提取元素dint
和SD
中的元素AA
和BB
data.frame同名的基本名称为short
del1
和del2
(请参阅我的 所需输出 >下面)?
注意: :HERE提供的解决方案忽略了后缀名,例如short..3
等。
G <- list(AA = list(short..3 = data.frame(dint = 5:7, SD = 0:2), short..2 = NULL, del1 = data.frame(dint = 1:3, SD = 2:4),
del1..2 = NULL, del2 = NULL),
BB = list(short = data.frame(dint = 1:4, SD = 2:5), short..2 = NULL, del1..4 =
data.frame(dint = 5:6, SD = 3:4), del1..2 = NULL, del2 = data.frame(dint = 6, SD = 1)) )
我想要的输出是(我希望内部名称(例如,“ short”不自动后缀):
# dints:
dints = list(
short = list(AA = c(short = 5:7), BB = c(short = 1:4)),
del1 = list(AA = c(del1 = 1:3), BB = c(del1 = 5:6)),
del2 = list(AA = c(del2 = NULL), BB = c(del2 = 6)))
# SDs:
SDs = list(
short = list(AA = c(short = 0:2), BB = c(short = 2:5)),
del1 = list(AA = c(del1 = 2:4), BB = c(del1 = 3:4)),
del2 = list(AA = c(del2 = NULL), BB = c(del2 = 1)))