geardf constructs a geardf, which is simply a data.frame with an attribute indicating which columns refer to the coordinates. The function either combines x and coords if coordnames
isn't provided, or identifies the columns of x to which coordnames refers. The geardf class is only provided to make plotting results of the predict.geolm* functions simple without depending on the sp or sf packages. See plot.geardf for easy plotting.
geardf(data, coords, coordnames)
Arguments
data: A data.frame
coords: A data.frame or matrix with column names
coordnames: The columns of data containing the spatial coordinates, provided as a formula (e.g., ~ x + y), column numbers (e.g., c(1, 2)), or column names (e.g., c("x", "y")). The default is NULL.
Returns
A geardf
Examples
dtf = data.frame(a =1:2, b =3:4)# create geardf with matrix coords (note column names)coords = matrix(rnorm(4), ncol =2)colnames(coords)= c("u","v")geardf(dtf, coords)# create geardf with data.frame coordscoords = as.data.frame(coords)geardf(dtf, coords)# create geardf using coordnamesdtf2 = cbind(dtf, u = rnorm(2), v = rnorm(2))# vector form of coordnamesgeardf(dtf2, coordnames = c("u","v"))# formula form of coordnamesgeardf(dtf2, coordnames =~ u + v)# column index forum of coordnamesgeardf(dtf2, coordnames =3:4)gdf = geardf(dtf2, coordnames =3:4)# looks like a data.framegdf
# but slightly more complicatedclass(gdf)attr(gdf,"coordnames")