Skip to contents

Create a new WeightResults object to store results for a solution.

Usage

new_weight_results(weight, held, id = uuid::UUIDgenerate())

Arguments

weight

Weight object.

held

numeric proportion of the weight covered by the solution. (e.g. 0.1 = 10%).

id

character unique identifier. Defaults to a random identifier (uuid::UUIDgenerate()).

Value

A WeightResults 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_from_auto(d, index = 1)

# create a new weight
w <- new_weight(name = "NDVI", variable = v)

# create a new weight results object to store results
wr <- new_weight_results(w, 80)

# print object
print(w)
#> Weight
#>   id:       09a1e9b1-4e17-452a-9ae7-52cc03e9396d
#>   name:     NDVI
#>   variable: .../sim_raster_spatial.tif#Brown_necked_Parrot_Brown_necked_ [total: 483 ]
#>   pane:  4375621f-dc5a-4a1a-a395-3eaffe1b461e-Brown_necked_Parrot_Brown_necked_
#>   current:  0
#>   visible:  TRUE
#>   invisible:  NA
#>   loaded:  TRUE
#>   hidden:  FALSE
#>   downloadable:  TRUE
#>   status:   TRUE
#>   factor:   0