as.geodata: Converts an Object to the Class "geodata"

as.geodataR Documentation

Converts an Object to the Class "geodata"

Description

The default method converts a matrix or a data-frame to an object of the class "geodata".
Objects of the class "geodata" are lists with two obligatory components: coords and data. Optional components are allowed and a typical example is a vector or matrix with covariate(s) values.

Usage

as.geodata(obj, ...)

## Default S3 method:
as.geodata(obj, coords.col = 1:2, data.col = 3, data.names = NULL, 
                   covar.col = NULL, covar.names = "obj.names",
                   units.m.col = NULL, realisations = NULL,
                   na.action = c("ifany", "ifdata", "ifcovar", "none"),
                   rep.data.action, rep.covar.action, rep.units.action,
                   ...)

## S3 method for class 'geodata'
as.data.frame(x, ..., borders = TRUE)

## S3 method for class 'geodata.frame'
as.geodata(obj, ...)

## S3 method for class 'SpatialPointsDataFrame'
as.geodata(obj, data.col = 1, ...)

is.geodata(x)

Arguments

obj

a matrix or data-frame where each line corresponds to one spatial location. It should contain values of 2D coordinates, data and, optionally, covariate(s) value(s) at the locations. A method for SpatialPointsDataFrame is also provided. It can also take an output of the function grf, see DETAILS below.

coords.col

a vector with the column numbers corresponding to the spatial coordinates.

data.col

a scalar or vector with column number(s) corresponding to the data.

data.names

optional. A string or vector of strings with names for the data columns. Only valid if there is more than one column of data. By default, takes the names from the original object.

covar.col

optional. A scalar or numeric vector with the column number(s) corresponding to the covariate(s). Alternativelly can be a character vector with the names of the covariates.

covar.names

optional. A string or vector of strings with the name(s) of the covariates. By default take the names from the original object.

units.m.col

optional. A scalar with the column number corresponding to the offset variable. Alternativelly can be a character vector with the name of the offset. This option is particularly relevant when using the package geoRglm. All values must be greater then zero.

realisations

optional. A vector indicating the realisation number or a number indicating a column in obj with the realisation indicator variable. See DETAILS below.

na.action

string defining action to be taken in the presence of NA's. The default option "ifany" excludes all points for which there are NA's in the data or covariates. The option "ifdata" excludes points for which there are NA's in the data. The default option "ifcovar" excludes all points for which there are NA's in the covariates. The option "none" do not exclude points.

rep.data.action

a string or a function. Defines action to be taken when there is more than one data at the same location. The default option "none" keeps the repeated locations, if any. The option "first" retains only the first data recorded at each location. Alternativelly a function can be passed and it will be used. For instance if mean is provided, the function will compute and return the average of the data at coincident locations. The non-default options will eliminate the repeated locations.

rep.covar.action

idem to rep.data.locations, to be applied to the covariates, if any. Defaults to the same option set for rep.data.locations.

x

an object which is tested for the class geodata.

rep.units.action

a string or a function. Defines action to be taken on the element units.m, if present when there is more than one data at the same location. The default option is the same value set for rep.data.action.

borders

logical. If TRUE the element borders in the geodata object is set as an attribute of the data-frame.

...

values to be passed for the methods.

Details

Objects of the class "geodata" contain data for geostatistical analysis using the package geoR. Storing data in this format facilitates the usage of the functions in geoR. However, conversion of objects to this class is not obligatory to carry out the analysis.

NA's are not allowed in the coordinates. By default the respective rows will not be included in the output.

Realisations
Tipically geostatistical data correspond to a unique realisation of the spatial process. However, sometimes different "realisations" are possible. For instance, if data are collected in the same area at different points in time and independence between time points is assumed, each time can be considered a different "replicate" or "realisation" of the same process. The argument realisations takes a vector indication the replication number and can be passed to other geoR functions as, for instance, likfit.

The data format is similar to the usual geodata format in geoR. Suppose there are realisations (times) 1, \ldots, J and for each realisations n_1, ..., n_j observations are available. The coordinates for different realisations should be combined in a single n \times 2 object, where n=n_1 + \ldots + n_J. Similarly for the data vector and covariates (if any).

grf objects
If an object of the class grf is provided the functions just extracts the elements coords and data of this object.

Value

An object of the class "geodata" which is a list with two obligatory components (coords and data) and other optional components:

coords

an n \times 2 matrix where n is the number of spatial locations.

data

a vector of length n, for the univariate case or, an n \times v matrix or data-frame for the multivariate case, where v is the number of variables.

covariates

a vector of length n or an n \times p matrix with covariate(s) values, where p is the number of covariates. Only returned if covariates are provided.

realisations

a vector on size n with the replication number. Only returned if argument realisations is provided.

Author(s)

Paulo Justiniano Ribeiro Jr. paulojus@leg.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.

References

Further information on the package geoR can be found at:
http://www.leg.ufpr.br/geoR/.

See Also

read.geodata for reading data from an ASCII file and list for general information on lists.

Examples

## Not run: 
## converting the data-set "topo" from the package MASS (VR's bundle)
## to the geodata format:
if(require(MASS)){
topo
topogeo <- as.geodata(topo)
names(topogeo)
topogeo
}

## End(Not run)

geoR documentation built on May 29, 2024, 1:36 a.m.

Related to as.geodata in geoR...