cubble {cubble}R Documentation

Create a cubble object

Description

Create a cubble object

Usage

cubble(..., key, index, coords)

make_cubble(spatial, temporal, by = NULL, key, index, coords)

Arguments

...

a set of name-value pairs to create a cubble, need to include the key, index, and coords variables.

key

a character (or symbol), the spatial identifier. See the Key section in tsibble::as_tsibble()

index

a character (or symbol), the temporal identifier. Currently support base R classes Date, POSIXlt, POSIXct and tsibble's tsibble::yearmonth(), tsibble::yearweek(), and tsibble::yearquarter() class. See the Index section in tsibble::as_tsibble()

coords

a vector of character (or symbol) of length two, in the order of longitude first and then latitude, the argument can be omitted if created from an sf and its subclasses. In case the sf geometry column is not POINT, coords will be the centroid coordinates.

spatial

a tibble object or an sf object, the spatial component containing the key and coords variable (coords can be automatically created from an sf object if not supplied).

temporal

a tibble object or a tsibble object, the temporal component containing the key and index variable.

by

in the syntax of the by argument in dplyr::left_join(), used in make_cubble() when the key variable has different names in the spatial and temporal data.

Value

a cubble object

Examples

cubble(
  id = rep(c("perth", "melbourne", "sydney"), each = 3),
  date = rep(as.Date("2020-01-01") + 0:2, times = 3),
  long = rep(c(115.86, 144.96, 151.21), each = 3),
  lat = rep(c(-31.95, -37.81, -33.87), each = 3),
  value = rnorm(n = 9),
  key = id, index = date, coords = c(long, lat)
  )

# stations and climate are in-built data in cubble
make_cubble(spatial = stations, temporal = meteo,
            key = id, index = date, coords = c(long, lat))


[Package cubble version 0.3.0 Index]