Station Name -> Time Series
sname2ts.Rd
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=1, 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 (seedates
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.
-) Ifdates
is a number (default), it indicates the index of the column inx
that stores the dates
-) Ifdates
is a factor, it is converted into Date class, using the date format specified bydate.fmt
-) Ifdates
is already of Date class, the code verifies that the number of days indates
be equal to the number of element inx
- date.fmt
character indicating the format in which the dates are stored in dates, e.g. %Y-%m-%d. See
format
inas.Date
.
ONLY required whenclass(dates)=="factor"
orclass(dates)=="numeric"
.- 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
-) Temperature =>FUN= mean
-) Flow =>FUN= mean
- 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 andtstep
is one ofmonthly
orannual
.
Function that have to be applied for transforming from daily to monthly or annual time step (e.g., for precipitationFUN=sum
and for temperature and flow ts,FUN=mean
)- 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 bydate.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 bydate.fmt
.
Author
Mauricio Zambrano-Bigiarini, mzb.devel@gmail
Examples
## 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")