View source: R/utils-usa-pull-data.R
usa_pull_data | R Documentation |
Extraction of
catch data,
weight measurements,
length measurements,
age reads, and
management quantities from NORPAC and PacFIN databases for the Pacific Hake assessment.
usa_pull_data(
password_file,
start_year = 1900,
end_year = get_data_yr(),
save_dir = fs::path(here::here(), "data-tables")
)
password_file |
A file path specifying where to find the passwords. The path can be full or relative to your current working directory. The text file must contain two lines, where the first line is the NORPAC password and the second line is the PacFIN password. These passwords should not be surrounded with quotes. If a file name is not provided, which is the default behavior, then the user will be prompted for their passwords. This also happens if the file cannot be found given the path provided. These passwords are needed because the databases store confidential information. |
start_year |
An integer value specifying the start year of data to include in the extraction. The default is 1900 to include all the data possible, including years where only a foreign fleet fished. |
end_year |
An integer value specifying the final year of data to include
in the extraction. The default uses |
save_dir |
A string specifying the full path to a directory where you
want files saved. The default is to save them in a folder found using
|
usa_pull_data()
includes several steps, outlined below, and leads to many
files being saved to your computer. Originally, files were NOT
overwritten. In 2022, Kelli F. Johnson changed the code to not save previous
downloads to save on disk space, reduce the storing of redundant information,
and simplify the code base that needed maintenance. The code steps through
the following steps:
Assign usernames and passwords, where the latter are read in from the specified file or obtained from the user.
Find the folder where the data should be saved, typically using
fs::path(here::here(), "data-tables")()
.
Extract data from NORPAC.
Catch data
Weight and age data
Squash table of ages (that also includes lengths)
Foreign ages
Species list
Extract data from PacFIN.
Catch data
Age, length, and weight data from bds table
At-sea data
Management quantities such as allowable catch limits (ACL) for the Pacific Fisheries Management Council, i.e., U.S. quantities of interest.
Save each object to the disk in the "extractedData" directory, which is created in the directory specified by save_dir if it does not already exist.
An environment or list
with several objects pulled from the desired
databases are returned invisibly. Additionally, several .Rdat
files are
saved to the disk in extractedData
, which is created inside of save_dir
.
The following files are saved:
nages.Rdat
nweight.Rdat
ncatch.Rdat
page.Rdat
pcatch.Rdat
pspec.Rdat
Kelli F. Johnson
get_data_yr()
## Not run:
# An environment with objects is returned
dataenv <- usa_pull_data()
# Access individual objects using `get()`
head(get("ncatch", envir = dataenv))
# Access individual objects pretending the environment is a list
dataenv[["ncatch"]][1:5, ]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.