dathomog {seas} | R Documentation |
Homogenize daily data sets
Description
Homogenizes daily data from two data sets into one data set; optionally show cross-plots to examine how well correlated that data sets are.
Usage
dathomog(x1, x2, by = "date", plot = FALSE)
Arguments
x1 |
a |
x2 |
a |
by |
name of common column, usually ‘date’, which is of
class |
plot |
|
Details
Data from x1
has priority over x2
. Where data from
x1
is either NA
or missing (outside of time range), data
from x2
will be used (if available). Otherwise data form
x1
will be used directly. Variables will be
homogenized where their names are identical, found using
names
.
The cross-plots of the data are shown only for interest. They show
useful correlation statistics, and a best-fit line using perpendicular
offsets (which are preferred in this case over traditional linear
regression). At some point, the equations for this line may be used to
adjust the values from x2
, however this can always be done
externally to this function by pre-processing x2
.
Value
Returns a data.frame
of seasonal data required by most functions
in seas. Variable names of the structure are found by a
union
of the names of x1
and x2
.
Warning
Weather stations should be sufficiently close enough to approximate the same weather. This distance depends on the spatial distance and local climatology.
Author(s)
Mike Toews
References
http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html
Examples
data(mscdata)
dat1 <- mksub(mscdata, id=2100630)
dat2 <- mksub(mscdata, id=1108447)
year.plot(dat1)
year.plot(dat2)
newdata <- dathomog(dat1, dat2)
year.plot(newdata)
message(paste(c("This is a rather poor example, since the",
"two stations are nowhere near each other"),
collapse="\n"))