Skip to content
Merged

Dev #54

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
627 changes: 627 additions & 0 deletions .github/pkg.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ jobs:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

# - name: Install remote dependencies
# run: |
# Rscript -e "pak::pkg_install('nmfs-general-modeling-tools/nmfspalette')"
# Rscript -e "pak::pkg_install('NOAA-EDAB/assessmentdata')"
# Rscript -e "pak::pkg_install('NOAA-EDAB/ecodata')"
# Rscript -e "pak::pkg_install('NOAA-EDAB/survdat')"
# Rscript -e "pak::pkg_install('NEFSC/READ_EDAB_Utilities@dev')"
#
# - name: Install dependencies
# run: Rscript -e "pak::lockfile_create(lockfile = '.github/pkg.lock')"

- uses: r-lib/actions/setup-r-dependencies@v2
with:
Expand Down
17 changes: 10 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ BugReports: https://github.com/NEFSC/READ-EDAB-NEesp2/issues
Depends:
R (>= 3.5.0)
Imports:
magrittr,
rlang
EDABUtilities (>= 0.0.0.9000),
janitor,
magrittr,
rlang
Suggests:
assessmentdata,
bookdown,
Expand All @@ -25,7 +27,6 @@ Suggests:
dplyr,
DT,
ecodata,
EDABUtilities,
flextable,
FSA,
ggnewscale,
Expand All @@ -38,11 +39,13 @@ Suggests:
knitr,
lintr,
lwgeom,
mockery,
nmfspalette,
pander,
papeR,
priceR,
rmarkdown,
rvest,
scales,
sf,
stringr,
Expand All @@ -54,13 +57,13 @@ Suggests:
utils,
viridis
VignetteBuilder:
rmarkdown
Remotes:
NEFSC/READ_EDAB_Utilities,
knitr
Remotes:
nmfs-general-modeling-tools/nmfspalette,
NOAA-EDAB/assessmentdata,
NOAA-EDAB/ecodata,
NOAA-EDAB/survdat
NOAA-EDAB/survdat,
EDABUtilities=NEFSC/READ_EDAB_Utilities@dev
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Expand Down
25 changes: 13 additions & 12 deletions R/create_spatial_indicator.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#' Create Spatial Indicator
#'
#' This function generates a spatially-aggregated indicator from a netCDF file.
#' The function passes data through EDABUtilities::make_2d_summary_ts, which provides summary statistics of 2d gridded data as time series by area.
#' Converts .nc files to data frame.
#' The function passes data through EDABUtilities::make_2d_summary_ts, which provides summary statistics of 2d gridded data as time series by area.
#' Parameters passed to EDABUtilities::make_2d_summary_ts are specified in the `...` argument and listed below:
#' data.in = Either a character vector of full input file names for a list of spatRasters
#' file.time = What time scale the input files are on ('daily','monthly','annual')? Assumes all monthly or annual files are on a daily timestep
#' output.files = vector of full output file names corresponding to each input file
#' shp.file = Shape file you wish to crop each input file to
#' var.name = Variable name you wish to extract.
#' area.names = Names of shape file areas you want to summarize.
#' statistic = Which statistic to calculate = 'mean'
#' agg.time = Time scale to calculate over (days, doy, months, season, or years)
#' tz = Time zone to convert. No correction if NA
#' touches = If TRUE, all cells touched by lines or polygons will be masked, not just those on the line render path, or whose center point is within the polygon
#' write.out = If TRUE, will write a netCDF file with output.files. If FALSE will return a list of spatRasters
#' @param indicator_name name of the indicator (character)
#' @param units units associated with the indicator (character)
#' @param ... passed to `EDABUtilities::make_2d_summary_ts`
#' @param data.in Either a character vector of full input file names for a list of spatRasters
#' @param file.time string. What time scale the input files are on ('daily','monthly','annual')? Assumes all monthly or annual files are on a daily timestep
#' @param output.files character vector of full output file names corresponding to each input file
#' @param shp.file string. Shape file you wish to crop each input file to
#' @param var.name string. Variable name you wish to extract.
#' @param area.names character vector. Names of shape file areas you want to summarize.
#' @param statistic string. Which statistic to calculate = 'mean'
#' @param agg.time character. Time scale to calculate over (days, doy, months, season, or years)
#' @param tz string. Time zone to convert. No correction if NA
#' @param touches logical. If TRUE, all cells touched by lines or polygons will be masked, not just those on the line render path, or whose center point is within the polygon
#' @param write.out logical. If TRUE, will write a netCDF file with output.files. If FALSE will return a list of spatRasters
#' @return Returns a data frame summarized by timestep for each area.names
#' @importFrom magrittr %>%
#' @importFrom rlang .data
Expand Down
15 changes: 7 additions & 8 deletions R/create_template.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
#'
#' This function creates an ESP two-pager template at the specified path.
#' @param path Where to create the template. Defaults to the present working directory.
#' @param over Logical. If TRUE, existing files will be overwritten. Defaults to FALSE.
#' @param over whether to overwrite existing files. Defaults to FALSE.
#' @export


create_template <- function(path = getwd(),
over = FALSE) {
create_template <- function(path = getwd(), over = FALSE) {
file.copy(
from = list.files(path = system.file(c("esp_template"),
package = "NEesp2"),
# recursive = TRUE,
full.names = TRUE),
from = list.files(
path = system.file(c("esp_template"), package = "NEesp2"),
# recursive = TRUE,
full.names = TRUE
),
to = path,
recursive = TRUE,
overwrite = over
Expand Down
48 changes: 24 additions & 24 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,30 @@
"survdat_subset"
#'
#'
#' @title DATASET_TITLE
#' @description DATASET_DESCRIPTION
#' @title Species lookup table from survdat
#' @description A species lookup table generated from survdat::get_species()
#' @format A data frame with 2047 rows and 21 variables:
#' \describe{
#' \item{\code{SCINAME}}{character COLUMN_DESCRIPTION}
#' \item{\code{COMNAME}}{character COLUMN_DESCRIPTION}
#' \item{\code{SVSPP}}{integer COLUMN_DESCRIPTION}
#' \item{\code{SVABBR}}{character COLUMN_DESCRIPTION}
#' \item{\code{PYSPP}}{double COLUMN_DESCRIPTION}
#' \item{\code{PYABBR}}{character COLUMN_DESCRIPTION}
#' \item{\code{NODCCODE}}{character COLUMN_DESCRIPTION}
#' \item{\code{NODCTYPE}}{logical COLUMN_DESCRIPTION}
#' \item{\code{NODCLEVL}}{character COLUMN_DESCRIPTION}
#' \item{\code{NODCCTRL}}{character COLUMN_DESCRIPTION}
#' \item{\code{NODCAUTH}}{character COLUMN_DESCRIPTION}
#' \item{\code{AUTHOR}}{character COLUMN_DESCRIPTION}
#' \item{\code{PICTURE}}{character COLUMN_DESCRIPTION}
#' \item{\code{COMMNT}}{character COLUMN_DESCRIPTION}
#' \item{\code{O_SVSCNM}}{character COLUMN_DESCRIPTION}
#' \item{\code{O_SVCONM}}{character COLUMN_DESCRIPTION}
#' \item{\code{O_SVSPP}}{integer COLUMN_DESCRIPTION}
#' \item{\code{DOC}}{character COLUMN_DESCRIPTION}
#' \item{\code{UOC}}{character COLUMN_DESCRIPTION}
#' \item{\code{DOE}}{character COLUMN_DESCRIPTION}
#' \item{\code{UOE}}{character COLUMN_DESCRIPTION}
#' \item{\code{SCINAME}}{character Scientific name of specimen.}
#' \item{\code{COMNAME}}{character Accepted common name of a fish or invertebrate species.}
#' \item{\code{SVSPP}}{integer A standard code which represents a species caught in a trawl or dredge.}
#' \item{\code{SVABBR}}{character Abbreviation of common name of specimen.}
#' \item{\code{PYSPP}}{double Prey species name.}
#' \item{\code{PYABBR}}{character Prey abbreviation.}
#' \item{\code{NODCCODE}}{character National Oceanographic Data Center (NODC) taxononic code for species.}
#' \item{\code{NODCTYPE}}{logical National Oceanographic Data Center (NODC) Type name code: S-scientific name, C-Common name}
#' \item{\code{NODCLEVL}}{character National Oceanographic Data Center (NODC) taxanomic level: P-Phylum, C-Class, O-Order, F-Family, G-Genus, S-Species}
#' \item{\code{NODCCTRL}}{character National Oceanographic Data Center (NODC).}
#' \item{\code{NODCAUTH}}{character NODC code author (person who described species).}
#' \item{\code{AUTHOR}}{character Author of document.}
#' \item{\code{PICTURE}}{character Citation for picture of species.}
#' \item{\code{COMMNT}}{character Comment related to species in SVDBS.SVSPECIES_LIST.}
#' \item{\code{O_SVSCNM}}{character Former scientific name used by Survey branch.}
#' \item{\code{O_SVCONM}}{character Former common name used by Survey branch.}
#' \item{\code{O_SVSPP}}{integer Former species code.}
#' \item{\code{DOC}}{character Date when the current record was updated or changed. Date format (MM/DD/YY HH:MI:SS)}
#' \item{\code{UOC}}{character The Oracle username of the individual who changed the current record.}
#' \item{\code{DOE}}{character Date when record was inserted into Oracle. Date format (MM/DD/YY HH:MI:SS).}
#' \item{\code{UOE}}{character The Oracle username of the individual who entered the new record.}
#'}
"species_data"
"species"
6 changes: 3 additions & 3 deletions R/get_mrip_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ save_trips <- function(
#' @param catch_type the type of catch to query. Can be "all" for all catch types (A, B1, B2), or "landings" for just the landings (A and B1). Default is "all".
#' @param wait whether to pause after saving the data. Default is TRUE.
#' @param return_fname whether to return the file name of the saved data. Default is TRUE.
#' @param this_data_type the type of data to query. Can be any or all of c("numbers of fish", "weight of fish (pounds)", "weight of fish (kilograms)", "mean length", "mean weight"). Default is "numbers of fish".
#' @return Saves list of the scraped data and metadata. Returns the file name.
#' @export

Expand All @@ -295,11 +296,10 @@ save_catch <- function(
this_region,
out_folder,
catch_type = "all",
# this_data_type,
this_data_type = "numbers of fish",
wait = TRUE,
return_fname = TRUE
) {

fname <- paste0(
out_folder,
"/catch_",
Expand All @@ -320,7 +320,7 @@ save_catch <- function(
species = this_species,
type = catch_type,
region = this_region,
# data_type = this_data_type
data_type = this_data_type
)

saveRDS(out, fname)
Expand Down
2 changes: 1 addition & 1 deletion R/table_report_card.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ format_tbl_data <- function(file,
term_year,
dir) {
if(stringr::str_detect(file, "csv$")) {
out <- base::read.csv(file)
out <- read.csv(file)
} else if(stringr::str_detect(file, "xlsx$")) {
out <- readxl::read_excel(file)
} else {
Expand Down
Loading
Loading