View source: R/geocode-utils.r
| split_geocodes | R Documentation |
Multiple geocodes can be stored as rows in a single data frame or as a named list of one row data frames. As metadata attributes lists are easier to manipulate, but when computing the sun position data frames are more efficient. These functions implement conversions between objects using these two approaches.
split_geocodes(geocode, idx = "spct.idx", simplify = TRUE)
bind_geocodes(geocode, idx = "spct.idx")
geocode |
data.frame with geocode data in columns |
idx |
character Name of the column where the ID factor is stored in geocode data frames with multiple rows. |
simplify |
logical Flag indicating if when the list to be returnes has a single member, the member geocode should be returned instead. |
Function split_geocodes() splits a multi-row data.frame
containing one geocode per row and a character vector or a
factor as ID column into a named list of one row data
frames containing the same geocode information. If the input is a
single-row data frame or a list with a single member, and
simplify = TRUE is passed in the call, a bare data frame is
returned, with the ID column, if present, deleted.
Function bind_geocodes() binds the geocodes members of a
list into a multirow data.frame containing one geocode per row and
a character vector ID column containing the same geocode
information.
A list of geo_code data frames or a single geocode data frame.
my.geocodes <- data.frame(lon = c(0, 10, 15),
lat = c(30, 60, 89),
address = c("one", "two", "three"),
spct.idx = c("A", "B", "C"))
split_geocodes(my.geocodes)
split_geocodes(my.geocodes[1, ])
my.list <- list("A" = data.frame(lon = 10,
lat = 30,
address = "North"),
"B" = data.frame(lon = -10,
lat = -30,
address = "South"))
bind_geocodes(my.list)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.