Description Usage Arguments Details Examples
Provide a function that creates a new dataset containing all paired observations, with distance and dependence measures.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | pairwise(x, ...)
## S3 method for class 'formula'
pairwise(xform, x, yform, y, method = "geo", htol = Inf,
pseudo = TRUE, coord = TRUE, pearson = TRUE, spearman = TRUE,
kendall = TRUE)
## S3 method for class 'formula'
pobs(form, x)
## S3 method for class 'data.frame'
pdist(y, method = "geo", htol = NULL, ...)
## S3 method for class 'formula'
pdist(form, y, method = "geo", htol = NULL, ...)
|
x, y |
Data.frame of the observation and station characteristics. |
method |
Type of distance to compute. Either 'geo' for geographical distance or 'euclidean' for euclidean distance. |
htol |
Threshold that limit the paired distances. |
pseudo |
If |
coord |
If |
pearson |
If |
spearman |
If |
kendall |
If |
form, xform, yform |
Formula that specify which variables
of |
With x
or the function pobs
, the formula is
of the form :
value ~ id + year
, which result in a data.frame with twice
the number of columns. In order, they represent the values that
composes the paired observation, the station identificator and
the time. This function is usually used for
transforming a dataset containing hydrological variables from
several station at several sampling times.
With y
or the function pdist
, the formula is of
the form :
id ~ lon + lat
, which returns a data.frame with twice
the number of columns, plus the paired distance and other
related measures of associations. In order the
variable represent the station identificator and the coordinates.
If method = 'euclidean'
the distance can be calculated
between stations characteristics. In the case of 3 variables,
the formula could be of the form : id ~ var1 + var2 + var3
.
The function pairwise
combine the result of pobs
and pdist
in a list and calculate measure of association
between the paired observations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | xdf <- data.frame(id = factor(c('a','a','b','b','b','c','c'),
levels = c('a','b','c','d')),
year = 2010 + c(1:2,1:3,1:2),
value = rlnorm(7))
pobs(value~id+year, xdf)
coord <- data.frame(id = c('a','b','c','d'),
lon = runif(4)-80,
lat = runif(4)+43)
pdist(id~lon+lat,coord)
pdist(id~lon+lat,coord, htol = 50)
pairwise(value~id+year, xdf, id~lon+lat,coord)
##################################################################
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.