From 8b1cac97d486ca5bc371bd307a0e70f286bb7947 Mon Sep 17 00:00:00 2001 From: andybeet <22455149+andybeet@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:55:24 -0400 Subject: [PATCH 1/2] removed ; after sql queries to prevent ROracle from throwing an error --- DESCRIPTION | 2 +- R/get_gears.R | 2 +- R/get_locations.R | 4 ++-- R/get_species_itis.R | 8 ++++---- R/get_vessels.R | 4 ++-- man/comlandr.Rd | 18 ++++++++++++++++++ man/get_areas.Rd | 2 +- man/get_gears.Rd | 2 +- man/get_locations.Rd | 4 ++-- man/get_ports.Rd | 2 +- man/get_vessels.Rd | 4 ++-- man/process_foreign_data.Rd | 2 +- 12 files changed, 36 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index db44c24..d31929c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,7 @@ Suggests: ggforce, NEFSCspatial VignetteBuilder: knitr -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Imports: data.table, sf, diff --git a/R/get_gears.R b/R/get_gears.R index 1614a80..cb6a76e 100644 --- a/R/get_gears.R +++ b/R/get_gears.R @@ -62,7 +62,7 @@ get_gears <- function(channel,gears="all") { query <- DBI::dbGetQuery(channel,sqlStatement) # get column names - sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'GEAR' and owner='CFDBS';" + sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'GEAR' and owner='CFDBS'" colNames <- DBI::dbGetQuery(channel,sqlcolName) return (list(data=dplyr::as_tibble(query),sql=sqlStatement, colNames=colNames)) diff --git a/R/get_locations.R b/R/get_locations.R index cc0085d..1f391fe 100644 --- a/R/get_locations.R +++ b/R/get_locations.R @@ -47,7 +47,7 @@ #' @export #' # -get_locations <- function(channel,sqlStatement="select * from cfdbs.loc;"){ +get_locations <- function(channel,sqlStatement="select * from cfdbs.loc"){ query <- DBI::dbGetQuery(channel,sqlStatement) @@ -56,7 +56,7 @@ get_locations <- function(channel,sqlStatement="select * from cfdbs.loc;"){ #save(species,file="data/speciesDefinitions.RData") # get column names - sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'LOC' and owner='CFDBS';" + sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'LOC' and owner='CFDBS'" colNames <- DBI::dbGetQuery(channel,sqlcolName) return (list(data=dplyr::as_tibble(query),sql=sqlStatement, colNames=colNames)) diff --git a/R/get_species_itis.R b/R/get_species_itis.R index 091b092..827926f 100644 --- a/R/get_species_itis.R +++ b/R/get_species_itis.R @@ -80,18 +80,18 @@ get_species_itis <- function(channel,species="all",nameType="common_name"){ sqlStatement <- sub(";","",sqlStatement) if (length(species) == 1) { if (tolower(species) == "all") { - sqlStatement <- paste0(sqlStatement," where NESPP4_FLAG = 1;") + sqlStatement <- paste0(sqlStatement," where NESPP4_FLAG = 1") } else { - sqlStatement <- paste0(sqlStatement," and NESPP4_FLAG = 1;") + sqlStatement <- paste0(sqlStatement," and NESPP4_FLAG = 1") } } else { - sqlStatement <- paste0(sqlStatement," and NESPP4_FLAG = 1;") + sqlStatement <- paste0(sqlStatement," and NESPP4_FLAG = 1") } query <- DBI::dbGetQuery(channel,sqlStatement) # get column names - sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'SPECIES_ITIS_NE' and owner='CFDBS';" + sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'SPECIES_ITIS_NE' and owner='CFDBS'" colNames <- t(DBI::dbGetQuery(channel,sqlcolName)) return (list(data=dplyr::as_tibble(query),sql=sqlStatement, colNames=colNames)) diff --git a/R/get_vessels.R b/R/get_vessels.R index 181af97..0c6bb75 100644 --- a/R/get_vessels.R +++ b/R/get_vessels.R @@ -49,7 +49,7 @@ get_vessels <- function(channel,sqlStatement="select * from cfdbs.mstrvess",wher #appends where if (!is.null(where)) { - sqlStatement <- paste(sqlStatement,"where",where,";") + sqlStatement <- paste(sqlStatement,"where",where) } query <- DBI::dbGetQuery(channel,sqlStatement) @@ -59,7 +59,7 @@ get_vessels <- function(channel,sqlStatement="select * from cfdbs.mstrvess",wher #save(species,file="data/speciesDefinitions.RData") # get column names - sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'MSTRVESS' and owner='CFDBS';" + sqlcolName <- "select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME = 'MSTRVESS' and owner='CFDBS'" colNames <- DBI::dbGetQuery(channel,sqlcolName) return (list(data=dplyr::as_tibble(query),sql=sqlStatement, colNames=colNames)) diff --git a/man/comlandr.Rd b/man/comlandr.Rd index aa88a5c..ae33d80 100644 --- a/man/comlandr.Rd +++ b/man/comlandr.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/comlandr.R \docType{package} \name{comlandr} +\alias{comlandr-package} \alias{comlandr} \title{comlandr: Pull and process commercial fisheries data} \description{ @@ -31,3 +32,20 @@ NAFO website: \url{https://www.nafo.int} #'To learn more about using \code{comlandr}, start with the vignette: \code{browseVignettes(package="comlandr")} or click the index below } +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/NOAA-EDAB/comlandr} + \item Report bugs at \url{https://github.com/NOAA-EDAB/comlandr/issues} +} + +} +\author{ +\strong{Maintainer}: Sean Lucey \email{sean.lucey@noaa.gov} + +Authors: +\itemize{ + \item Andy Beet \email{andrew.beet@noaa.gov} +} + +} diff --git a/man/get_areas.Rd b/man/get_areas.Rd index 5f397d9..48aa058 100644 --- a/man/get_areas.Rd +++ b/man/get_areas.Rd @@ -60,8 +60,8 @@ Other get functions: \code{\link{get_gears}()}, \code{\link{get_locations}()}, \code{\link{get_ports}()}, -\code{\link{get_species_itis}()}, \code{\link{get_species}()}, +\code{\link{get_species_itis}()}, \code{\link{get_vessels}()} } \concept{get functions} diff --git a/man/get_gears.Rd b/man/get_gears.Rd index b211b98..0d824b5 100644 --- a/man/get_gears.Rd +++ b/man/get_gears.Rd @@ -60,8 +60,8 @@ Other get functions: \code{\link{get_areas}()}, \code{\link{get_locations}()}, \code{\link{get_ports}()}, -\code{\link{get_species_itis}()}, \code{\link{get_species}()}, +\code{\link{get_species_itis}()}, \code{\link{get_vessels}()} } \concept{get functions} diff --git a/man/get_locations.Rd b/man/get_locations.Rd index 45fe1e0..c51eacd 100644 --- a/man/get_locations.Rd +++ b/man/get_locations.Rd @@ -4,7 +4,7 @@ \alias{get_locations} \title{Extract LOCATION information from CFDBS} \usage{ -get_locations(channel, sqlStatement = "select * from cfdbs.loc;") +get_locations(channel, sqlStatement = "select * from cfdbs.loc") } \arguments{ \item{channel}{DBI Object. Inherited from \link[DBI]{DBIConnection-class}. This object is used to connect @@ -56,8 +56,8 @@ Other get functions: \code{\link{get_areas}()}, \code{\link{get_gears}()}, \code{\link{get_ports}()}, -\code{\link{get_species_itis}()}, \code{\link{get_species}()}, +\code{\link{get_species_itis}()}, \code{\link{get_vessels}()} } \concept{get functions} diff --git a/man/get_ports.Rd b/man/get_ports.Rd index 5b40e10..358bc4b 100644 --- a/man/get_ports.Rd +++ b/man/get_ports.Rd @@ -61,8 +61,8 @@ Other get functions: \code{\link{get_areas}()}, \code{\link{get_gears}()}, \code{\link{get_locations}()}, -\code{\link{get_species_itis}()}, \code{\link{get_species}()}, +\code{\link{get_species_itis}()}, \code{\link{get_vessels}()} } \concept{get functions} diff --git a/man/get_vessels.Rd b/man/get_vessels.Rd index 188d89f..efec5e2 100644 --- a/man/get_vessels.Rd +++ b/man/get_vessels.Rd @@ -63,7 +63,7 @@ Other get functions: \code{\link{get_gears}()}, \code{\link{get_locations}()}, \code{\link{get_ports}()}, -\code{\link{get_species_itis}()}, -\code{\link{get_species}()} +\code{\link{get_species}()}, +\code{\link{get_species_itis}()} } \concept{get functions} diff --git a/man/process_foreign_data.Rd b/man/process_foreign_data.Rd index 1af0e87..b59edb3 100644 --- a/man/process_foreign_data.Rd +++ b/man/process_foreign_data.Rd @@ -4,7 +4,7 @@ \alias{process_foreign_data} \title{Processes NAFO data for comlandr use} \usage{ -process_foreign_data(channel, nafoland, useHerringMaine) +process_foreign_data(channel, nafoland, useLanded = T, useHerringMaine = T) } \arguments{ \item{channel}{an Object inherited from \link[DBI]{DBIConnection-class}. This object is used to connect From 2044b2bebc13790274fe1a136eaeb03d02719407 Mon Sep 17 00:00:00 2001 From: andybeet <22455149+andybeet@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:18:08 -0400 Subject: [PATCH 2/2] changed schema for herring data --- R/get_herring_data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_herring_data.R b/R/get_herring_data.R index 8df2398..188084f 100644 --- a/R/get_herring_data.R +++ b/R/get_herring_data.R @@ -26,7 +26,7 @@ get_herring_data <- function(channel, comland, filterByYear, filterByArea, herr.qry <- paste0("select year, month, category, stock_area, negear, gearname, keptmt, discmt - from cfdbs.maine_herring_catch + from NEFSC_GARFO.maine_herring_catch where year ", years) if(!is.na(filterByArea[1])){ herr.qry <- paste0(herr.qry, " and stock_area in (", survdat:::sqltext(filterByArea), ")