fill_dvenv: Fill an R Environment with Streamflow Partitioning Analyses...

Description Usage Arguments Value Note Author(s) See Also Examples

Description

Fill an R environment with R data.frames of daily-mean streamflow for USGS streamgages. This function is a wrapper (abstraction layer) on the dvget function.

Usage

1
2
fill_dvenv(siteNumbers, envir=NULL,   sdates=NULL,  edates=NULL,
                        flowlos=NULL, flowhis=NULL, silent=FALSE, ...)

Arguments

siteNumbers

A vector of USGS streamgage identification numbers;

envir

The R environment to use and required to be user created by new.env();

sdates

A vector of starting dates (possibly unique by streamgage) to feed the similarly named argument of dvget with string format of “YYYY-MM-DD” for year (YYYY), month (MM), and day (DD) respectively padded by zeros as needed. Use "" for earliest date, and for convenience, a vector of length 1 (unity) is recycled to form a vector with as many elements as length if siteNumbers;

edates

A vector of ending dates (possibly unique by streamgage) to feed the similarly named argument of dvget with string format of “YYYY-MM-DD” for year (YYYY), month (MM), and day (DD) respectively padded by zeros as needed. Use "" for latest date, and for convenience, a vector of length 1 (unity) is recycled to form a vector with as many elements as length if siteNumbers;

flowlos

A vector of lower streamflow thresholds (likely unique by streamgage) to feed the similar named argument of dvget;

flowhis

A vector of upper streamflow thresholds (likely unique by streamgage) to feed the similar named argument of dvget;

silent

Suppress informative calls to message(); and

...

Additional arguments to pass to control dvget.

Value

An R environment is returned.

Note

Emergency intervention or other types of bulk filtering on the environment can be accomplished with code like this for an environment named old_dv:

1
2
3
4
5
  for(site in ls(old_dv)) {
     ZZ <- get(site, envir=old_dv)
     ZZ <- ZZ[ZZ$year > 1984 & ZZ$year < 1997,] # just keep 1985--1996
     assign(site, ZZ, envir=old_dv)
  }

However, such an operation would be destructive to the old_dv environment. An independent copy of the environment could first be made:

1
2
3
4
5
6
  new_dv <- list2env(as.list(newdv)) # Note that "new_dv <- old_dv" is not a copy!
  for(site in ls(new_dv)) {
     ZZ <- get(site, envir=new_dv)
     ZZ <- ZZ[ZZ$month <= 3 | ZZ$month >= 10,] # just keep Oct--Dec, Jan--Mar
     assign(site, ZZ, envir=new_dv)
  }

Author(s)

W.H. Asquith

See Also

dvget, akqdecay, fill_akqenv, fill_dvpartenv, dvoverlap

Examples

1
2
3
4
5
6
7
8
## Not run: 
# Six USGS streamgages of the Wolf River in Tennessee
wolfriver <- c("07030392", "07030500", "07031650",
               "07031660", "07031700", "07031740")
wolf.env <- new.env() # the standard declaration of an environment
fill_dvenv(wolfriver, envir=wolf.env) # wolf.env now filled with six tables.
# and wolf.env is shown within the Examples of fill_akqenv and fill_dvpartenv. #
## End(Not run)

wasquith-usgs/akqdecay documentation built on Nov. 9, 2020, 1:13 p.m.