active {sfdep} | R Documentation |
Activate spacetime context
Description
From a spacetime
object, activate either the data or geometry contexts. The active object will then become available for manipulation.
Usage
active(.data)
activate(.data, what)
Arguments
.data |
a spacetime object |
what |
default NULL. Determines which context to activate. Valid argument values
are |
Details
A spacetime
object contains both a data frame and an sf object. The
data frame represents geographies over one or more time periods and the sf
object contains the geographic information for those locations.
Value
For activate()
an object of class spacetime with the specified context activated. active()
returns a scalar character with the active context can be either "goemetry" or "data".
Examples
df_fp <- system.file("extdata", "bos-ecometric.csv", package = "sfdep")
geo_fp <- system.file("extdata", "bos-ecometric.geojson", package = "sfdep")
# read in data
df <- read.csv(
df_fp, colClasses = c("character", "character", "integer", "double", "Date")
)
geo <- sf::st_read(geo_fp)
# Create spacetime object called `bos`
bos <- spacetime(df, geo,
.loc_col = ".region_id",
.time_col = "time_period")
active(bos)
activate(bos, "geometry")
[Package sfdep version 0.2.4 Index]