Introduction

This is an internal R package for the Hakai Institute Juvenile Salmon Program. It is primarily a data package that contains citable versions of the Hakai Institute Juvenile Salmon Program (JSP) data. The purpose of this package is to:

  • provide a common data resource for researchers to work from;
  • make it as easy as possible to load salmon program data into R-Studio;
  • facilitate collaborative development of custom functions for summarizing and analyzing program data;
  • produce versioned sets of data and functions to ensure analytical reproducibility;
  • serve as a formal framework for open science data sharing, collaboration, and contribution

For a full description of what is in this package, see the Reference section of this website. As new data are available, this package will be updated and new versions will be released. Check back to see if the package is updated before starting or finalizing an analysis. In the Changelog section of this website you can find release notes about changes to the package or underlying data.

If you would like to suggest improvements, features, or bug fixes to this package please do so at https://github.com/HakaiInstitute/hakaisalmon/issues. If you would like to modify any part of this package you are encouraged to submit a pull request. If neither of those previous statements make much sense to you then I’ll point you to the Hakai Institute R Stats Guide which outlines many of the collaborative data science workflows this R package is premised on.

Installation

First , make sure you have a free GitHUB account. You’ll need to be added as an external collaborator to the private hakaisalmon package repository once you have a GitHUB account. Contact the package maintainer to request this.

Once you have access to the repository, go to https://github.com/settings/tokens. Check the repo box, and scroll down and hit generate token.

Copy the token.

In the R-Studio console run the following two lines of code:

install.packages("devtools")

devtools::install_github("HakaiInstitute/hakaisalmon", auth_token = "PASTE YOUR TOKEN HERE")

Usage

All program data and functions are loaded into memory upon calling library(hakaisalmon). You will not see the salmon program data frames as objects in the environment pane of R-Studio, but to demonstrate that the data is loaded into memory begin to type survey in your script and you should see several JSP data tables pop up in the tab completion window.

All the tables from the program database are available and their variables are all documented in the reference tab of this website. Explore the Reference section to see what tables this package contains, and click on the table name to see descriptions of variable.

Some of the more common joins of data tables have already be completed for convenience, for example survey_seines_fish. If you wish to join other tables you can do so using the dplyr join functions. If this is something you have to do often, consider including your custom join in this package by submitting an issue, or by submitting a pull request.

A typical analysis using data that is loaded into memory from the hakaisalmon package might start like this:

library(hakaisalmon)
library(tidyverse)
sockeye_2017_lengths <- survey_seines_fish %>% # survey_seines_fish is already loaded into memory :)
  filter(lubridate::year(survey_date) == 2017, species == "SO") %>% 
  select(survey_date, species, fork_length) %>% 
  drop_na("fork_length")
  
print(sockeye_2017_lengths)
## # A tibble: 381 x 3
##    survey_date species fork_length
##    <date>      <chr>         <int>
##  1 2017-05-25  SO              130
##  2 2017-05-25  SO              114
##  3 2017-05-25  SO              143
##  4 2017-05-25  SO              147
##  5 2017-05-25  SO              126
##  6 2017-05-25  SO              127
##  7 2017-05-25  SO              112
##  8 2017-05-25  SO              140
##  9 2017-05-25  SO              150
## 10 2017-05-25  SO              113
## # ... with 371 more rows

Citing Data

Please cite the Hakai Institute GeoNetwork metadata catalogue entry.

Hunt, B.P.V., B.T. Johnson, J.C.L. Gan, C.V. Janusson. 2018. The Hakai Institute Juvenile Salmon Program. http://dx.doi.org/10.21966/1.566666. Version X.X.X