Skip to contents

This function will read in the Excel file from the provided path and perform a standardized series of cleaning steps that always need to be performed on ECCC-FLNR MAMU radar survey data prior to any analyses.

Usage

process_radar_data(path, site_groupings)

Arguments

path

File path to radar data Excel file.

site_groupings

(optional) Dataframe of site name groups with two columns: 1) original_name and 2) new_name.

Value

A dataframe of cleaned radar data.

Details

The function first performs a few housekeeping tasks:

  • Make R-friendly column names

  • Create the survey_date column from the year, month, and day columns

  • Re-calculate day-of-year (doy)

  • Fix minor typos, e.g. "Skwakwa" -> "Skwawka"

It then filters down the data with the following criteria:

  • Include only "Complete" surveys

  • Include only pre-dawn surveys (i.e., after 2 am and before 8 am)

  • Exclude August surveys

  • Exclude Alaska border region surveys

Finally, it creates the new_name column, which groups sites with slightly different names that should really be a single site. The user can either rely on the default radar site name changes that are bundled in this package (see ?rs), or they can specify their own as a dataframe in the site_groupings param.

Site groupings

Site groupings must be provided as a dataframe with two columns: original_name and new_name, where the original_name column contains site names found in the raw data and the new_name column contains name you want the site to be renamed to. Run data(rs) for an example of the default name changes bundled with this package.

Examples

# Clean using function defaults
process_radar_data("~/Documents/path/to/radar/data.xlsx")
#> Error: `path` does not exist: ‘~/Documents/path/to/radar/data.xlsx’

# Provide your own site groupings
sg <- data.frame(original_name = c("Fairfax 2", "Coleman Boat", "Nekite 1", "Nekite 2"),
                 new_name = c("Fairfax", "Coleman", "Nekite", "Nekite"))
process_radar_data("~/Documents/path/to/radar/data.xlsx",
                   site_groupings = sg)
#> Error: `path` does not exist: ‘~/Documents/path/to/radar/data.xlsx’