Create a new Variable object using metadata. This function is useful when pre-calculated are available, so that previously calculated metadata can be used.
new_variable_from_metadata(dataset, metadata)
dataset |
|
---|---|
metadata |
|
The argument to metadata
should contain the following elements:
character
or integer
indicating the field/layer
with the data within the dataset that has the data.
character
units for the values in the underlying data.
character
indicating if the data contain
continuous ("continuous"
) or categorical ("categorical"
) values.
character
indicating the data source.
(see new_provenance_from_source()
).
character
vector containing colors for visualization.
numeric
sum of all values in dataset.
numeric
minimum value in dataset.
Required only for continuous data.
numeric
maximum value in dataset.
Required only for continuous data.
numeric
vector of unique value in dataset.
Required only for categorical data.
character
vector of unique labels for manual legend.
Required only for categorical data, manual legend.
# 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_from_metadata(
d, list(
index = 1, units = "ha", type = "continuous",
colors = c("#000000", "#AAAAAA"), total = 12,
min_value = 1, max_value = 3, provenance = "missing",
labels = "missing"
)
)
# print object
print(v)
#> Variable
#> dataset: .../sim_raster_spatial.tif
#> index: Brown_necked_Parrot_Brown_necked_
#> total: 12
#> units: ha
#> provenance: missing