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 extractOz functions.

Usage

df_to_list(x, names = 1, lonlat = 2:3)

Arguments

x

data.frame. A three column object with the first column being the location name, the second longitude, named "x", and the third, latitude, named "y", as decimal degrees in numeric format.

names

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

lonlat

Vector. A set of integer values indicating the column index in which the longitude and latitude values are contained. Defaults to 2:3.

Value

A list object suitable for use in any of the extract functions in extractOz.

Author

Adam H. Sparks, adamhsparks@gmail.com

Examples

library(readr)

read_csv(system.file(
  "extdata",
  "sample_points.csv",
  package = "extractOz",
  mustWork = TRUE
)) |>
  df_to_list(names = 1, lonlat = 2:3)
#> Rows: 3 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (1): site
#> dbl (2): x, y
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> $Merredin
#>      x      y 
#> 118.28 -31.48 
#> 
#> $Corrigin
#>      x      y 
#> 117.87 -32.33 
#> 
#> $Tamworth
#>      x      y 
#> 150.84 -31.07 
#>