TSstormstats: Compute various time-series summary statistics between...

View source: R/TSstormstats.R

TSstormstatsR Documentation

Compute various time-series summary statistics between specified time periods

Description

Compute various stats for time series data over a period of time Can be used for time series data with equally spaced time increments. File format must include the POSIXct formatted date and columns of values with the time series data

Usage

TSstormstats(
  df,
  date = "pdate",
  varname,
  dates,
  starttime = "Ebpdate",
  endtime = "Eepdate",
  stats.return = c("mean"),
  subdfvar = "",
  subdfvalue = "",
  subdatesvar = "",
  subdatesvalue = "",
  out.varname = ""
)

Arguments

df

dataframe with unit values values and date/time in POSIX

date

string name of POSIX date column

varname

string column with unit values in df

dates

dataframe with sample dates

starttime

string Column in sample dates data fram with dates in POSIX format used for extracting summary data from dates dataframe This date serves as the beginning date of the summary period, default is "psdate"

endtime

string Column in sample dates data fram with dates in POSIX format used for extracting summary data from dates dataframe This date serves as the ending date of the summary period, default is "pedate"

stats.return

string vector Options include = c("mean","max","min","median","sum") specification of stats to apply to the time series data. Current options include mean, max, min, median, sum, difference, nearest, and nearprev. difference is the latest minus the first value, nearest is the closest value in time to starttime, nearprev is the closest value previous to starttime, nearest and nearprev require a 0 in the times vector.

subdfvar

string subset df data frame by a value in this column

subdfvalue

string value to use in subsetting df

subdatesvar

string subset dates data frame by a value in this column

subdatesvalue

string value to use in subsetting

out.varname

string variable name for resulting column

Value

dates dataframe

Examples

flowData <- flowData
sampleData <- sampleData
TSstormstats(df=flowData,date="pdate",varname="Q",
      dates=sampleData,starttime="Hbpdate",endtime="Hepdate",
      stats.return=c("mean","max","sd"),out.varname="Q")

USGS-R/USGSHydroTools documentation built on April 17, 2023, 8:09 p.m.