dathomog: Homogenize daily data sets In seas: Seasonal Analysis and Graphics, Especially for Climatology

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

 `1` ```dathomog(x1, x2, by = "date", plot = FALSE) ```

Arguments

 `x1` a `data.frame` of seasonal data; 1st selection `x2` a `data.frame` or seasonal data; 2nd selection `by` name of common column, usually ‘date’, which is of class `Date` `plot` `logical`; produce cross-plots and correlation statistics of the variables between the two data sets

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.

Mike Toews

References

http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html

Examples

 ``` 1 2 3 4 5 6 7 8 9 10``` ```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")) ```

Example output

```Loading required package: MASS\nWarning messages:\n1: input string \'\xb0\' cannot be translated to UTF-8, is it valid in \'ANSI_X3.4-1968\'? \n2: input string \'\xb0\' cannot be translated to UTF-8, is it valid in \'ANSI_X3.4-1968\'? \nWarning messages:\n1: input string \'\xb2\' cannot be translated to UTF-8, is it valid in \'ANSI_X3.4-1968\'? \n2: input string \'\xb2\' cannot be translated to UTF-8, is it valid in \'ANSI_X3.4-1968\'? \nThis is a rather poor example, since the\ntwo stations are nowhere near each other\nsh: 1: rm: Permission denied\n
```

seas documentation built on May 2, 2019, 4:16 a.m.