I have two matrices, of latitude and longitude, both of which are 50 column x 1 million (e.g.) rows. I need to create a list of 1 million tibbles, each 2 columns - lon and lat - and 50 rows. My current code is:
lonlat <- list()
for (i in 1:nrow(lon)) {
lonlat[[i]] <- tibble(lon = lon[i, ], lat = lat[i, ])
}
I'm aware that this is incredibly inefficient, but I can't get my head around how I'd do this with purrr
. I feel like map2
could be the answer, but I suspect I'm not thinking about this the right way, and possibly I should reorganise the input matrices in order to make it a simpler task.
Does anyone have any experience with purrr
/map2
, or this kind of problem? Thanks in advance for any ideas.