add_variable_spdf: Adds variable(s) to a Spatial*DataFrame

Description Usage Arguments Value Examples

View source: R/add_variable.R

Description

Adds variable(s) to a Spatial*DataFrame

Usage

1

Arguments

spdf

A Spatial*DataFrame object

df

A vector or a data frame

Value

An object of the same class than sp.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# download vietnam admin1 administrative map in the internal library and in
# the working direction
vn <- sptools::gadm("vietnam", "sp", 1, intlib = TRUE, save = TRUE)
vn
vn <- add_variable_spdf(vn, rnorm(63))
vn

# The name of the new variable will be "df". To prevent that we could choose
# the data frame format:
vn <- add_variable_spdf(vn, data.frame(normal = rnorm(63)))
vn

# The data frame format allows the additional possibility to add several
# additional variables all at once:
vn <-  add_variable_spdf(vn,
  data.frame(uniform = runif(63), exponential = rexp(63)))
vn

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.