簡體   English   中英

將列表列表轉換為R中的向量列表

[英]convert list of lists to list of vectors in R

我有一個要更改為數字向量列表的數字列表。 我該怎么辦?

這就是我所擁有的

>coords
[[1]]
[1] -106.24328   39.00774

[[2]]
[1] -106.18677   38.83261

[[3]]
[1] -106.1493   38.8303

> class(coords[1])
[1] "list"
> class(coords[1[1]])
[1] "list"
> 

我想要的是

>coords
[1] -106.24328   39.00774
[2] -106.18677   38.83261
[3] -106.1493   38.8303

coords對象似乎是一個list 要將其轉換為具有2列的matrix ,我們可以rbind list元素。

m1 <- do.call(rbind, coords)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM