| mksub {seas} | R Documentation |
Make a subset of seasonal data
Description
Creates a subset of a data.frame with temporal observations,
using IDs and start and ending dates or years.
Usage
mksub(x, start, end, id)
Arguments
x |
a data frame with temporal observations |
start |
either a starting |
end |
either an ending |
id |
unique station identifier (if present), which is assumed to
be a column of |
Details
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.
Value
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")).
Author(s)
Mike Toews
See Also
Examples
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")))