knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The html_vignette output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The html_vignette format:

Load example deployment data and format it

library(seabiRds)

# Get path to the example deployment data
fn <- system.file("extdata/ecotone", "ecotone_ex.csv", package = "seabiRds")

# Read in data from this file
raw_dep <- read.csv(fn, stringsAsFactors = F)

# Look at head of the data
head(raw_dep)

We will add an empty field for deployment ID, named 'dep_id'. This will be passed to the formatDeployments() function, which will build a unique identified for each row based on the band number and the deployment date.

# Create a field called dep_id, where all values are NA
raw_dep$dep_id <- NA

In formatDeployments() we map the names of the fields in our raw data with the standard field names in the function. We will use fill_dep_id = T, to create unique deployment IDs from the data. In this example we will only use GPS data, however TDR units were also used in these deployments so we will map both the GPS and TDR fields.

For Ecotone data, it is important that the gps_id values in the deployment data match the logger IDs in the Ecotone data.

# Run formatDeployments
dep_data <- formatDeployments(
  deployments = raw_dep,
  dateFormat = "%Y-%m-%d %H:%M",
  dep_tz = "US/Eastern",
  species = 'Species',
  metal_band = 'Band_num',
  colour_band = 'Colour_band',
  dep_id = 'dep_id',
  fill_dep_id = T,
  site = 'Colony',
  dep_lon = 'Dep_lon',
  dep_lat = 'Dep_lat',
  time_released = 'Time_on',
  time_recaptured = 'Time_off',
  status_on = 'Stage_on',
  status_off = 'Stage_off',
  mass_on = 'Mass_on',
  mass_off = 'Mass_off',
  gps_id = 'GPS',
  tdr_id = 'TDR'
)

In the output, the dep_id field is now filled with ids for each deployment. The time_released and time_recaptured fields have been formatted as POSIXct data and converted to UTC. The last seven fields are added for compatibility with our biologging database. If you do not need these fields, you can ignore them or delete them.

# Look at the results
head(dep_data)

Read example Ecotone GPS data

# Get the path to the example data stored within this package
folder <- paste0(find.package('seabiRds'), "/extdata/ecotone/gps_data")

# Run the readGPSData function for Ecotone data
ecotone_data <- readGPSData(
  inputFolder = folder, # path to the colder storing the raw GPS files
  deployments = dep_data, # formatted deployment data
  tagType = "Ecotone"
)

# Look at the output
head(ecotone_data)
ecotone_data <- cleanGPSData(data = ecotone_data,
                            deployments = dep_data,
                            speedThreshold = 150,
                            plot =T)


allisonglider/seabiRds documentation built on Feb. 14, 2025, 7:37 a.m.