Skip to contents

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 "geometry" and "data". If left null, returns x.

x

a spacetime object

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.

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 <- readr::read_csv(df_fp, col_types = "ccidD")
geo <- sf::read_sf(geo_fp)

# Create spacetime object called `bos`
bos <- spacetime(df, geo,
                 .loc_col = ".region_id",
                 .time_col = "time_period")

active(bos)
#> [1] "data"
activate(bos, "geometry")
#> Error in UseMethod("activate"): no applicable method for 'activate' applied to an object of class "c('spacetime', 'spec_tbl_df', 'tbl_df', 'tbl', 'data.frame')"