Learn R Programming

seas (version 0.2-1)

mksub: Make a subset of climate data

Description

Creates a subset of a data.frame of climate data.

Usage

mksub(dat, start, end, id, rm.id = TRUE)

Arguments

dat
climate data frame
start
start year; if omitted minimum year will be used
end
end year; if omitted will use same as start, and if start is omitted, will use maximum year
id
unique station identifier used to extract a subset of data from dat
rm.id
logical; removes id field from dat, default is TRUE

Value

  • Returns a subset of a data.frame with the same fields as dat, except for id (if it is present and rm.id = TRUE).

Details

This utility function is useful for creating temporal subsets of climate data and for extracting a single station out of a data.frame with multiple climate stations. The dat object can have other fields (other than the standard set of fields), which will be returned. If id is used, that station will be extracted from dat. The returned object will no longer have an id field, unless rm.id = FALSE. If id is not provided, but there are more than one unique IDs in dat, the first unique ID will be extracted, with a warning.

See Also

read.msc

Examples

Run this code
data(mscstn)
data(mscdata)

dim(mksub(mscdata, id=1108447))
dim(mksub(mscdata, id=1108447, start=1980))
dim(mksub(mscdata, id=1108447, start=1980, end=1989))

Run the code above in your browser using DataLab