Skip to contents

A 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 in numeric format.

locations

Integer or column name. The column in which the location names are located. Defaults to 1.

lonlat

Vector. A set of two integer indices or column names indicating the columns in which the longitude and latitude values are contained, in that order. Defaults to 2:3.

call

The environment used for error reporting.

Value

A named list object suitable for use in any of the extract_() functions in fifo.

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 
#>