mksub | 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 |
end |
either an ending |
id |
unique station identifier (if present), which is assumed to
be a column of |
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")
).
Mike Toews
read.msc
, mscdata
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")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.