0

我有一个包含 12 个条目的列表。

[[1]]
     event_id   time_occurred        
[1,] "MX050113" "2013-03-29 05:45:03"
[2,] "MX050112" "2013-03-29 05:43:03"
[3,] "MX050113" "2013-03-29 05:42:03"
[4,] "MX050110" "2013-03-29 05:41:03"
[5,] "MX050513" "2013-03-29 05:39:03"
[6,] "MX050113" "2013-03-29 05:38:03"`

[[2]]
      event_id   time_occurred        
[1,] "MX050117" "2013-03-29 06:47:03"
[2,] "MX050122" "2013-03-29 06:44:03"
[3,] "MX050213" "2013-03-29 06:42:03"
[4,] "MX050160" "2013-03-29 06:40:03"
[5,] "MX020513" "2013-03-29 06:38:03"`

[[3]]
  .
  .
  .
[[12]]

现在在 [[1]]..[[12]] 中,如何读取 [[1]] 中位置 [1,2] 的 header == time_occurred 下的数据?我不能给你这个列表的 R 代码,所以请建议我查询的语法。

4

1 回答 1

2

你有一堆矩阵,你想提取每个矩阵的第二列。所以使用lapply

lapply(lst, function(x) x[, 2])
于 2013-07-18T09:33:21.053 回答