swh:1:snp:33a53053e50f7abe7d281cc0c803be827debf4a3
Raw File
Tip revision: 0c875d17884c427fbe488f676a4a6da747240594 authored by Edzer Pebesma on 01 October 2011, 09:16:01 UTC
version 1.0-5
Tip revision: 0c875d1
gstat.formula.R
# $Id: gstat.formula.q,v 1.8 2007-06-08 06:45:52 edzer Exp $

"gstat.formula" <-
function (formula, data)
{
	# check for duplicated pixels; if yes coerce to SpatialPointsDataFrame:
	if (is(data, "SpatialPixels") && anyDuplicated(data@grid.index) != 0)
		gridded(data) = FALSE

    m = model.frame(terms(formula), as(data, "data.frame"))
    Y = model.extract(m, "response")
    if (length(Y) == 0)
        stop("no response variable present in formula")
    Terms = attr(m, "terms")
    X = model.matrix(Terms, m)
    has.intercept = attr(Terms, "intercept")

	if (gridded(data))
		grid = gridparameters(data)
	else
		grid = numeric(0)

    list(y = Y, locations = coordinates(data), X = X, call = call,
        has.intercept = has.intercept, grid = as.double(unlist(grid)))
}
back to top