I have a list of list of numbers that I want to change to a list of vectors of numbers. How could I do that?
Here's what I have,
>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"
>
What I want is
>coords
[1] -106.24328 39.00774
[2] -106.18677 38.83261
[3] -106.1493 38.8303
The coords
object seems to be a list
. To convert it to a matrix
with 2 columns, we can rbind
the list
elements.
m1 <- do.call(rbind, coords)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.