geardf: Construct a 'geardf'

Description Usage Arguments Value See Also Examples

View source: R/geardf.R

Description

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.

Usage

1
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.

Value

A geardf

See Also

plot.geardf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 coords
coords = as.data.frame(coords)
geardf(dtf, coords)

# create geardf using coordnames
dtf2 = cbind(dtf, u = rnorm(2), v = rnorm(2))
# vector form of coordnames
geardf(dtf2, coordnames = c("u", "v"))
# formula form of coordnames
geardf(dtf2, coordnames = ~ u + v)
# column index forum of coordnames
geardf(dtf2, coordnames = 3:4)

gdf = geardf(dtf2, coordnames = 3:4)
# looks like a data.frame
gdf
# but slightly more complicated
class(gdf)
attr(gdf, "coordnames")

gear documentation built on April 14, 2020, 5:12 p.m.

Related to geardf in gear...