new_variable: New variable

View source: R/class_Variable.R

new_variableR Documentation

New variable

Description

Create a new Variable object.

Usage

new_variable(
  dataset,
  index,
  units,
  total,
  legend,
  provenance = new_provenance_from_source("missing")
)

Arguments

dataset

Dataset file path for the dataset.

index

character or integer indicating the field/layer with the data.

units

character units for the values in the underlying data.

total

numeric total amount of all values in the underlying data.

legend

Legend object.

provenance

Provenance object. Defaults to new_provenance_from_source("missing").

Value

A Variable object.

Examples

# find data file paths
f1 <- system.file(
  "extdata", "projects", "sim_raster", "sim_raster_spatial.tif",
  package = "wheretowork"
)
f2 <- system.file(
  "extdata",  "projects", "sim_raster", "sim_raster_attribute.csv.gz",
  package = "wheretowork"
)
f3 <- system.file(
  "extdata",  "projects", "sim_raster", "sim_raster_boundary.csv.gz",
  package = "wheretowork"
)

# create new dataset
d <- new_dataset(f1, f2, f3)

# create new variable
v <- new_variable(d,
  index = 1, total = 12, units = "ha",
  legend = new_continuous_legend(1, 100, c("#000000", "#AAAAAA"))
)

# print object
print(v)

NCC-CNC/wheretowork documentation built on Feb. 27, 2025, 6:11 p.m.