R中数据帧作为向量的行列表

时间:2022-03-18 18:36:45

How can I convert rows into vectors in a list across multiple data frames?
I've been having the issue that after converting my rows into list form using:

如何将行转换为跨多个数据帧的列表中的向量?在使用以下方法将我的行转换为列表形式后,我一直遇到这样的问题:

pck <- list(NB[1,],NY[1,],AZ[1,],TB[1,])

I get the error

我收到了错误

Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
  'x' must be atomic

when I view my list pck I see:

当我查看我的列表时,我看到:

> pck
[[1]]
         V1        V2       V3      V4
1 0.6190389 0.9105718 2.020711 1.99928

[[2]]
         V1        V2       V3      V4
1 0.6190389 0.9105718 2.020711 1.99928

[[3]]
        V1       V2       V3       V4
1 2.286501 1.395356 1.544924 1.435426

[[4]]
         V1       V2       V3       V4
1 0.9035451 1.637073 2.830873 4.209193

How can I convert my list to a set of atomic vectors such that I can use functions like boxplot? That is, how can I most simply coerce pck into a form like this:

如何将我的列表转换为一组原子向量,以便我可以使用像boxplot这样的函数?也就是说,我怎样才能最简单地将pck强制转换成这样的形式:

> pck
[[1]]
[1] 0.6190389 0.9105718 2.020711 1.99928

[[2]]
[1] 0.6190389 0.9105718 2.020711 1.99928

[[3]]
[1] 2.286501 1.395356 1.544924 1.435426

[[4]]
[1] 0.9035451 1.637073 2.830873 4.209193

1 个解决方案

#1


0  

Try

尝试

pck <- lapply(pck, unlist, use.names = F)

#1


0  

Try

尝试

pck <- lapply(pck, unlist, use.names = F)