load_coordinates(): Load a CSV file containing named coördinates and
return an sf object. It uses utils::read.csv() to read the
data. In the function definition, it is assumed that the CSV file contains a
column named "Coordinates_WGS84" that contains the coördinates in the format
"Latitude, Longitude". The function uses tidyr::separate() to split
the coördinates into two separate columns, "Latitude" and "Longitude". The
function also assumes that the coördinates are in the WGS 84 format, and it
uses sf::st_as_sf() to convert the data to an sf object with
the coördinates as the geometry column.
Usage
load_coordinates(
  data = NULL,
  path = list("data", "raw", "NDC_datapoints.csv"),
  sep = ";",
  sep_col = "Coordinates_WGS84",
  into = c("Latitude", "Longitude"),
  col_order = c("Longitude", "Latitude"),
  separate_sep = ",",
  factor_cols = c("County", "Place"),
  mutate_col = "Type",
  mutate_val = "Participant home town/self-defined dialect",
  mutate_after = "geometry"
)Arguments
- data
- An optional data frame containing coördinates, default is - NULL
- path
- A list of character strings specifying the path to the CSV file, default is - here::here("data", "raw", "NDC_datapoints.csv")
- sep
- The separator used in the CSV file, default is - ";"
- sep_col
- The name of the column containing the coördinates, default is - "Coordinates_WGS84"
- into
- A character vector of length 2 specifying the names of the columns, default is - c("Latitude", "Longitude")
- col_order
- A character vector of length 2 specifying the order of the columns, default is - c("Longitude", "Latitude")
- separate_sep
- The separator used to separate the coördinates into two columns, default is - ","
- factor_cols
- A character vector of column names to convert to factors, default is - c("County", "Place")
- mutate_col
- The name of the column to mutate, default is - Type
- mutate_val
- The value to assign to the mutated column, default is - "Participant home town/self-defined dialect"
- mutate_after
- The name of the column after which to insert the mutated column, default is - "geometry"
