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.
df_to_list(x, names = 1, lonlat = 2:3)
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.
Integer
. The column in which the location names are located.
Defaults to 1.
Vector
. A set of integer
values indicating the column index
in which the longitude and latitude values are contained. Defaults to 2:3
.
A list
object suitable for use in any of the extract
functions
in extractOz.
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
#>