getDFE: DataForEver database API

View source: R/dfe_wq.R

getDFER Documentation

DataForEver database API

Description

Downloads and compiles DataForEver water quality or hydrology data.

Usage

getDFE(dbname = "hydrology", stn    = "S333", startDate = NULL,
endDate   = NULL, params    = NULL, matricesToExclude = "analyte_free_water",
rFriendlyParamNames = FALSE, data_shape = "long", addWaterQuality = FALSE,
addWaterQualityParams = NULL)

Arguments

dbname

name of the database sought for inquiry. Currently only 'hydrology' and 'waterquality' are supported. A case-insensitive character string.

stn

pattern to be matched in station names ('NULL' or 'all' return all stations). This argument applies only to water quality database. A case-insensitive grep-friendly single character element (e.g., 'S333|S197' to search for multiple stations).

startDate

start of desired date range (if NULL, the first date in period of record is used)

endDate

end of desired date range (if NULL, the latest date in period of record is used)

params

grep-style character vector naming analytes of interest. default is "all".

matricesToExclude

character vector specifying any sample matrices to be excluded. Spelling/case must be a perfect match to DataForEver entries. For example, "analyte_free_water" indicates field blanks. Advisible to check output using, e.g., unique(wqDat$matrix)

rFriendlyParamNames

TRUE/FALSE; indicates whether parameter names should be modified to be R-friendly (no special characters, commas, or spaces). Advisable for analysis, as this makes analysis easier and pre-empts changes coerced by, e.g., plyr::ddply

data_shape

shape of output dataframe. Default is long (one row per date-station-param) but can also be wide (one row per date-station) or really_wide (one row per date). If multiple observations are available for a date, they are averaged if this argument is set to 'wide' or 'really_wide'.

addWaterQuality

if ‘dbname = ’hydrology'', setting this to TRUE will allow wq data to be downloaded and merged internally

addWaterQualityParams

if hydrologic and water quality parameters are collected simultaneously, this argument specifies the water quality parameters

Value

dataframe getDFE returns a dataframe with observations from each station identified in stn argument.

See Also

getDFE

Examples


## Not run: 
### to check hydro parameter names:
# getParams_DFE(dbname = "hydrology")$datatype
a1 <- getDFE(stn = c("S12A", "S333"), dbname = "hydrology", params = "head_water|flow",
             startDate = "2018-01-01")

a2 <- getDFE(stn = c("S12A", "S333"), dbname = "waterquality", startDate = "2018-01-01")
unique(a2$stn)



## End(Not run)


troyhill/SFNRC documentation built on Dec. 30, 2024, 4:32 p.m.