Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 提取列表元素_R - Fatal编程技术网

R 提取列表元素

R 提取列表元素,r,R,I'v跟随整形中的llply函数的输出 df <- structure(list(Loc1 = structure(list(tables = structure(list( `Grand mean` = 6.86966666666667, Entry = structure(c(5.67, 7.375, 6.465, 5.95, 6.695, 5.875, 7.46, 6.17, 8.555, 5.415, 7.91, 7.815, 6.415, 8.035, 7

I'v跟随
整形
中的
llply
函数的输出

df <-
structure(list(Loc1 = structure(list(tables = structure(list(
    `Grand mean` = 6.86966666666667, Entry = structure(c(5.67,
    7.375, 6.465, 5.95, 6.695, 5.875, 7.46, 6.17, 8.555, 5.415,
    7.91, 7.815, 6.415, 8.035, 7.24), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.536212022742248, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc2 = structure(list(tables = structure(list(`Grand mean` = 7.42966666666667,
    Entry = structure(c(7.95, 6.595, 7.07, 9.35, 8.355, 6.955,
    7.435, 7.42, 7.83, 7.105, 8.64, 6.16, 7.85, 7.17, 5.56), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.565181386813118, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc3 = structure(list(tables = structure(list(`Grand mean` = 3.6391,
    Entry = structure(c(3.788, 4.7345, 3.5905, 3.6285, 3.954,
    3.533, 0.824500000000001, 4, 3.3295, 3.413, 3.1815, 3.744,
    4.821, 4.5695, 3.475), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.519259954165541, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc4 = structure(list(tables = structure(list(`Grand mean` = 3.41326666666667,
    Entry = structure(c(2.967, 4.089, 3.244, 2.581, 3.133, 2.874,
    3.321, 3.7065, 3.475, 3.9375, 3.5265, 2.992, 4.3175, 3.26,
    3.775), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.527952523118004, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc5 = structure(list(tables = structure(list(`Grand mean` = 3.6835,
    Entry = structure(c(3.504, 3.149, 3.2595, 4.0985, 3.42, 4.007,
    4.7835, 3.6615, 3.8575, 3.0235, 4.5785, 2.6305, 3.4685, 3.395,
    4.416), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.371149430822681, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc6 = structure(list(tables = structure(list(`Grand mean` = 3.22453333333333,
    Entry = structure(c(3.4805, 2.6675, 2.82, 3.5555, 2.436,
    3.323, 2.8595, 3.259, 3.713, 2.79, 3.213, 4.0015, 3.317,
    3.654, 3.2785), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.437812821496432, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
))), .Names = c("Loc1", "Loc2", "Loc3", "Loc4", "Loc5", "Loc6"
))
lapply(df, "[", "se") ...........

但我想通过一个电话就能得到这些se。但我不明白这一点。我非常感谢你的帮助。谢谢

我想您正在寻找:

unlist(sapply(df,'[[',"se"))

另一方面,据我所知,
llply
plyr
的函数,而不是
重塑

我想您正在寻找:

df <-
structure(list(Loc1 = structure(list(tables = structure(list(
    `Grand mean` = 6.86966666666667, Entry = structure(c(5.67,
    7.375, 6.465, 5.95, 6.695, 5.875, 7.46, 6.17, 8.555, 5.415,
    7.91, 7.815, 6.415, 8.035, 7.24), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.536212022742248, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc2 = structure(list(tables = structure(list(`Grand mean` = 7.42966666666667,
    Entry = structure(c(7.95, 6.595, 7.07, 9.35, 8.355, 6.955,
    7.435, 7.42, 7.83, 7.105, 8.64, 6.16, 7.85, 7.17, 5.56), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.565181386813118, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc3 = structure(list(tables = structure(list(`Grand mean` = 3.6391,
    Entry = structure(c(3.788, 4.7345, 3.5905, 3.6285, 3.954,
    3.533, 0.824500000000001, 4, 3.3295, 3.413, 3.1815, 3.744,
    4.821, 4.5695, 3.475), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.519259954165541, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc4 = structure(list(tables = structure(list(`Grand mean` = 3.41326666666667,
    Entry = structure(c(2.967, 4.089, 3.244, 2.581, 3.133, 2.874,
    3.321, 3.7065, 3.475, 3.9375, 3.5265, 2.992, 4.3175, 3.26,
    3.775), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.527952523118004, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc5 = structure(list(tables = structure(list(`Grand mean` = 3.6835,
    Entry = structure(c(3.504, 3.149, 3.2595, 4.0985, 3.42, 4.007,
    4.7835, 3.6615, 3.8575, 3.0235, 4.5785, 2.6305, 3.4685, 3.395,
    4.416), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.371149430822681, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc6 = structure(list(tables = structure(list(`Grand mean` = 3.22453333333333,
    Entry = structure(c(3.4805, 2.6675, 2.82, 3.5555, 2.436,
    3.323, 2.8595, 3.259, 3.713, 2.79, 3.213, 4.0015, 3.317,
    3.654, 3.2785), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.437812821496432, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
))), .Names = c("Loc1", "Loc2", "Loc3", "Loc4", "Loc5", "Loc6"
))
unlist(sapply(df,'[[',"se"))
lapply(df, "[", "se") ...........

另一方面,据我所知,
llply
plyr
的一个函数,而不是
重塑

谢谢你的回答和更正。如果您能指导我如何在一次通话中做到这一点,我将不胜感激。谢谢,我不明白这个问题。(我在你的例子中没有看到任何可以用这些索引引用的项目。)我想你可以用
sappy(ANOVAs,[',2,3)
来做这件事,我不确定,因为我自己无法尝试。可能需要再次取消它的列表。感谢你的回答和更正。如果你能指导我如何做
ANOVAs$Loc1[2,3],ANOVAs$Loc2[2,3],…
在一次通话中。谢谢。我不明白这个问题。(我在你的示例中没有看到可以用这些索引引用的项目。)我认为你可以用
sapply(ANOVAs,“[”,2,3)做到这一点
,不确定,因为我自己无法尝试。可能需要再次取消它的列表。感谢您的回答。如果您能指导我如何在一次通话中使用ANOVAs$Loc1[2,3],ANOVAs$Loc2[2,3]…将不胜感激。感谢使用
'['
,而不是
'[['
确实给出了一个稍微奇怪的输出,即一个列表,其中每个元素都是一个包含一个元素的列表,这是标准错误。是的。很好,这个学习者能够体验到这种差异。似乎他在投票支持你的版本,我同意人们通常所期望的。谢谢你的回答。如果你能提供指导,我将不胜感激告诉我如何在一次通话中完成ANOVAs$Loc1[2,3],ANOVAs$Loc2[2,3]…感谢使用
'['
而不是
'[['
确实给出了一个稍微奇怪的输出,即一个列表,其中每个元素都是一个包含一个元素的列表,这是一个标准错误。是的。很好,这个学习者能够体验到这种差异。似乎他在投票支持你的版本,我同意人们通常所期望的。
df <-
structure(list(Loc1 = structure(list(tables = structure(list(
    `Grand mean` = 6.86966666666667, Entry = structure(c(5.67,
    7.375, 6.465, 5.95, 6.695, 5.875, 7.46, 6.17, 8.555, 5.415,
    7.91, 7.815, 6.415, 8.035, 7.24), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.536212022742248, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc2 = structure(list(tables = structure(list(`Grand mean` = 7.42966666666667,
    Entry = structure(c(7.95, 6.595, 7.07, 9.35, 8.355, 6.955,
    7.435, 7.42, 7.83, 7.105, 8.64, 6.16, 7.85, 7.17, 5.56), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.565181386813118, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc3 = structure(list(tables = structure(list(`Grand mean` = 3.6391,
    Entry = structure(c(3.788, 4.7345, 3.5905, 3.6285, 3.954,
    3.533, 0.824500000000001, 4, 3.3295, 3.413, 3.1815, 3.744,
    4.821, 4.5695, 3.475), .Dim = 15L, .Dimnames = structure(list(
        Entry = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
        "10", "11", "12", "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.519259954165541, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc4 = structure(list(tables = structure(list(`Grand mean` = 3.41326666666667,
    Entry = structure(c(2.967, 4.089, 3.244, 2.581, 3.133, 2.874,
    3.321, 3.7065, 3.475, 3.9375, 3.5265, 2.992, 4.3175, 3.26,
    3.775), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.527952523118004, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc5 = structure(list(tables = structure(list(`Grand mean` = 3.6835,
    Entry = structure(c(3.504, 3.149, 3.2595, 4.0985, 3.42, 4.007,
    4.7835, 3.6615, 3.8575, 3.0235, 4.5785, 2.6305, 3.4685, 3.395,
    4.416), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.371149430822681, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
)), Loc6 = structure(list(tables = structure(list(`Grand mean` = 3.22453333333333,
    Entry = structure(c(3.4805, 2.6675, 2.82, 3.5555, 2.436,
    3.323, 2.8595, 3.259, 3.713, 2.79, 3.213, 4.0015, 3.317,
    3.654, 3.2785), .Dim = 15L, .Dimnames = structure(list(Entry = c("1",
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15")), .Names = "Entry"), class = "mtable")), .Names = c("Grand mean",
"Entry")), n = structure(2L, .Names = "Entry"), se = structure(list(
    Entry = structure(0.437812821496432, .Dim = c(1L, 1L), .Dimnames = list(
        "2", "2"))), .Names = "Entry", type = "means", class = "mtable")), .Names = c("tables",
"n", "se"), type = "means", class = c("tables_aov", "list.of"
))), .Names = c("Loc1", "Loc2", "Loc3", "Loc4", "Loc5", "Loc6"
))
lapply(df, "[", "se") ...........