| mksub {seas} | R Documentation |
Creates a subset of a data.frame with temporal observations,
using IDs and start and ending dates or years.
mksub(x, start, end, id)
x |
a data frame with temporal observations |
start |
either a starting Date or
integer year; if omitted minimum will be used |
end |
either an ending Date or year; if omitted will use
same year as start, and if start is omitted, will use
maximum year |
id |
unique station identifier (if present), which is assumed to
be a column of x as x$id; it is used to extract a
subset of data from a single ID |
This utility function is useful for creating temporal subsets of
seasonal data and for extracting a single station out of a
data.frame with multiple stations or sets. The x
object can have many columns, representing measured variables for each
day, which will be returned with their original attributes.
If id is used, that station will be extracted from
x. If id is not provided, but there are more than one
unique IDs in x$id, the first unique ID will be extracted, with
a warning.
Returns a subset of a data.frame with the same columns
and attributes as x, except id, which will be retained
as an attribute (e.g., attr(x,"id")).
M.W. Toews
data(mscstn)
data(mscdata)
# All available data from one station
summary(mksub(mscdata, id=1108447))
# One year
str(mksub(mscdata, id=1108447, start=1980))
# A range of years
str(mksub(mscdata, id=1108447, start=1980, end=1989))
# A range of dates
summary(mksub(mscdata, id=1108447,
start=as.Date("1975-08-01"),
end=as.Date("2000-07-31")))