The following list is the result of using st_intersects()
of the sf
package. It contains numeric vectors, varying by length:
require(sf)
require(tidyverse)
mylist <- structure(list(c(1L, 71L, 168L, 672L), c(1L, 71L, 99L, 619L), c(3L, 47L,51L),
c(32L, 43L, 76L, 78L, 318L, 411L), c(4L, 143L, 344L, 363L, 724L),
c(4L, 17L, 251L, 327L, 330L, 344L, 363L, 450L, 724L),
c(44L, 75L, 79L, 124L, 172L, 204L, 339L, 350L, 382L, 383L,
404L, 405L, 409L, 540L, 554L, 562L, 605L, 623L, 661L, 689L),
c(405L, 605L), c(124L, 249L, 339L, 540L, 605L, 661L),
c(8L, 13L, 175L, 187L)), predicate = "intersects",
region.id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"),
ncol = 825L, class = c("sgbp", "list"))
I would like to extract the numeric vectors from the list into a tibble (or dataframe) and preserve their ordering.
That is, I would like to obtain an object which looks like
ID V1
1 1L
1 71L
1 168L
1 672L
2 1L
2 71L
2 99L
2 619L
...
How would I achieve the above, preferrably in dplyr
?