Learn R Programming

hydroTSM (version 0.3-5)

sname2ts: Station Name -> Time Series

Description

This function takes a data.frame whose columns contains the time series of several gauging stations, along with a character representing the name of one gauging station, and extracts the time series corresponding to that station.

Usage

sname2ts(x, sname, dates, date.fmt = "%Y-%m-%d", var.type, 
         tstep.out = "daily", FUN, na.rm = TRUE, from, to)

Arguments

x
data.frame containing the complete times series of all the stations. It may also contain 1 column with the dates of the measurements, or they can be provided in a different way (see dates below).
sname
Character representing the name of a station, which have to correspond to one column name in x
dates
numeric, factor, Date object indicating how to obtain the dates corresponding to the sname station. -) If dates is a number, it indicates the index of the column in x that stores the dates -) If dates
date.fmt
character indicating the format in which the dates are stored in dates, e.g. %Y-%m-%d. See format in as.Date. ONLY required when class(dates)=="factor" o
var.type
character representing the type of variable being plotted. Used for determining the function used for computing the monthly or/and annual values when FUN is missing. Valid values are: -) Precipitation => FUN=sum -)
tstep.out
character that defines the time step of the desired output time series. Valid values are: -) daily : daily time series -) monthly: monthly time series -) annual : annual time series
FUN
ONLY required when var.type is missing and tstep is one of monthly or annual. Function that have to be applied for transforming from daily to monthly or annual time step (e.g., for precipitation F
na.rm
a logical value indicating whether 'NA' values should be stripped before the computation proceeds.
from
OPTIONAL, used for extracting a subset of values. Character indicating the starting date for the values to be extracted. It must be provided in the format specified by date.fmt.
to
OPTIONAL, used for extracting a subset of values. Character indicating the ending date for the values to be extracted. It must be provided in the format specified by date.fmt.

Value

  • zoo object

See Also

sname2plot

Examples

Run this code
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

## Annual values of temperature at the station "T9105", stored in 'EbroPPtsMonthly'.
sname2ts(EbroPPtsMonthly, sname="P9001", dates=1, FUN=sum, tstep.out="annual")

Run the code above in your browser using DataLab