-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetdata_function.R
More file actions
31 lines (22 loc) · 863 Bytes
/
getdata_function.R
File metadata and controls
31 lines (22 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#-----------------------------------------------------#
# Function to import data and add important variables #
#-----------------------------------------------------#
#' Packages
library('tidyverse')
#' Path to imported files
INDIVIDUAL_DATA_PATH <- "data/individual_data.csv"
SPECIES_CODE_PATH <- "data/species_codes.csv"
SITE_CODES_PATH <- "data/site_codes.csv"
#'Function to import dummy dataset
getdata_dummy <- function() {
df <- readr::read_csv(INDIVIDUAL_DATA_PATH)
species_code <- readr::read_csv(SPECIES_CODE_PATH)
site_codes <- readr::read_csv(SITE_CODES_PATH)
# Add vernacular name
df <- df |>
left_join(species_code |> select(speciesID, vernacularName), by = "speciesID")
# Add site name
df <- df |>
left_join(site_codes |> select(siteID, siteName), by = "siteID")
return(df)
}