getWData: getWData

getWDataR Documentation

getWData

Description

Gets data from Characteristic objects and formats it for ease in analysis.

Usage

getWData(
  object,
  parkcode = NA,
  sitecode = NA,
  charname = NA,
  category = NA,
  mindate = NA,
  maxdate = NA,
  months = NA,
  years = NA,
  wyears = NA,
  minvalue = NA,
  maxvalue = NA,
  minobs = 1,
  output = "dataframe"
)

Arguments

object

Either a Characteristic object a Site object, a Park object or a list of such objects.

parkcode

One or more parkcodes, in quotes. If object is a Park object or a list of Park objects, then the parkcode argument can be used to select which sites should be used.

sitecode

One or more sitecodes, in quotes. If object is a Park object or a list of Park or Site objects, then the sitcode argument can be used to select which sites should be used.

charname

Name of one or more characteristics, in quotes. Only those characteristics will be returned.

category

One or more categories of characteristics, in quotes. Only those categories of characteristics will be returned.

mindate

The earliest date of data to include, in quotes. Date is in the same format as the Date in the Data slot.

maxdate

The latest date of data to include, in quotes. Date is in the same format as the Date in the Data slot.

months

A numeric vector corresponding to months of the year. Only data from those months will be returned.

years

A numeric vector corresponding to calendar years. Only data from those months will be returned.

wyears

A numeric vector corresponding to water years. Only data from those water years will be returned.

minvalue

A number, indicating that only measurements with values greater than or equal to minvalue should be returned.

maxvalue

A number, indicating that only measurements with values less than or equal to maxvalue should be returned.

minobs

An integer indicating the minimum number of observations needed for a dataset to be returned. T his is assessed after the other filters are applied. Defaults to 0.

output

Either "dataframe", the default, or "list". Determines the type of output when data from more than one characteristic or site are returned. If dataframe is chosen then a single data.frame is returned. If list is chosen then it returns a list of data.frames, where each element is a unique site and characteristic.

Details

This function is intended to be the primary method for accessing water data. Data from various objects (see below) is combined into a single data.frame along with columns indicating which park/site/characteristic the data is from.

If object is a Characteristic object getWData will return a data.frame with columns consisting of Date and Value from the Data slot as well as a column named Characteristic with the data from the charname slot. and a column named Category iwth data from the category slot. If object is a Site object it will return a data.frame that also includes a column named Site which comes from the SiteCode slot. If object is a Park object then a column named Park is included which comes from the ParkCode slot.

Data can be filtered in a variety of ways. A date range can be selected by using the mindate and/or maxdate arguments. Dates passed to these arguments must be in text format and the same format as the dates in the data. The months argument will filter for data from one or more months. This argument requires months to be listed as one or more integers, e.g. months=c(3,4) will return only data collected in March or April. If NA is passed to months (the default), or NA is an element of the vector passed to months then data from all months will be returned. The years argument works in the same way, except that it only returns data from specific years. The wyears argument is the similar to years except that it filters by "water year". USGS water years start on October 1st and end on September 30th, so water year 2010 went from October 1st 2009 through September 30th 2010.

If an Characteristic object has an empty data slot, or the filtering options are such that no data meets the criteria, then the function returns NULL. NULL is also returned if after filtering there are fewer observations than minobs. This can be useful when getting data for analysis or graphics and you only wish to use datasets with sufficient observations.

Value

A data.frame or list based on the Data slot of Charactersitic objects.


NCRN/NCRNWater documentation built on May 15, 2023, 9:50 p.m.