2012-03-30 5 views
0

llply의 출력을 다음과 같이 reshape에 출력합니다.목록의 요소를 추출하는 중

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" 
)) 

나는 목록의 각 요소에서 se를 얻고 싶습니다. 이처럼 개별 요소에 대해이 작업을 수행 할 수 있습니다.

df$Loc1$se 
df$Loc2$se 
df$Loc3$se 
df$Loc4$se 
df$Loc5$se 
df$Loc6$se 

하지만 저는이 호출을 한 번만 호출하려고합니다. 그러나 나는 이것을 알 수 없다. 나는 당신의 도움에 감사드립니다. 감사합니다

답변

2

나는 당신이 찾고있는 생각 :

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

또 다른 메모에서, 지금까지의 내가 llply 알고 plyr하지 reshape의 함수입니다.

+0

멋진 답변과 수정을 보내 주셔서 감사합니다. ANOVAs $ Loc1 [2, 3], ANOVAs $ Loc2 [2, 3], ...를 한 번에 호출하는 방법을 안내해 주시면 감사하겠습니다. 감사합니다 – MYaseen208

+0

나는 그 질문을 이해하지 못합니다. (나는 당신의 예제에서 그 색인으로 참조 될 수있는 항목을 보지 않는다.) –

+0

나는 당신이'sapply (ANOVAs, '['2,3)'로 그렇게 할 수 있다고 생각한다. 그것을 직접 시험해 보라. 다시 목록에 올릴 필요가 있습니다. –

1
lapply(df, "[", "se") ........... 
+0

좋은 답변 주셔서 감사합니다. 당신이 저에게 ANOVAs $ Loc1 [2, 3], ANOVAs $ Loc2 [2, 3], ...를 한 번에 호출하는 방법을 안내해 주시면 감사하겠습니다. 감사합니다. – MYaseen208

+0

''[[ ''대신''[ ''를 사용하면 약간 더 경미한 결과를 얻을 수 있습니다. 즉, 각 요소는 하나의 요소가 표준 오류 인 목록입니다. –

+0

예. 이 학습자가 차이를 경험할 수 있다는 점을 잘 알고 있습니다. 그것은 그가 사람들이 일반적으로 기대하는 바에 동의하는 당신의 버전에 투표하는 것처럼 보입니다. –

관련 문제