cubble-class: Create a cubble object

cubbleR Documentation

Create a cubble object

Description

Create a cubble object

Usage

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

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

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.

potential_match

a key_tbl object from check_key(). When unmatched key values appear in spatial and temporal data, make_cubble will prompt the user to use check_key() for checking. This argument allow the check result to be parsed back to make_cubble to also match the potential_pairs found by the check.

key_use

a character of either "spatial" or "temporal". When potential_math is activated, this argument specifies which key column in the potential match to use. Default to "temporal".

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))


cubble documentation built on Sept. 11, 2024, 7:19 p.m.