
Convert a data frame object to a list suitable for use
Source:R/internal_functions.R
dot-df_to_list.RdA helper function to convert data.frames or objects inheriting from
data.frame, e.g., tibble::tibble or data.table::data.table into
a list suitable for use in fifo functions.
Usage
.df_to_list(xy, locations = 1L, lonlat = 2L:3L, call = rlang::caller_env())Arguments
- xy
data.frame. An object with one column of location names, one of longitude and one of latitude as decimal degrees innumericformat.- locations
Integeror column name. The column in which the location names are located. Defaults to1.- lonlat
Vector. A set of twointegerindices or column names indicating the columns in which the longitude and latitude values are contained, in that order. Defaults to2:3.- call
The environment used for error reporting.
Author
Adam H. Sparks, adamhsparks@gmail.com
Examples
d <- data.frame(
location = c("Merredin", "Corrigin"),
lon = c(118.28, 117.87),
lat = c(-31.48, -32.33)
)
fifo:::.df_to_list(d, locations = 1, lonlat = 2:3)
#> $Merredin
#> x y
#> 118.28 -31.48
#>
#> $Corrigin
#> x y
#> 117.87 -32.33
#>