Appends rows to the object's attribute table. A row names the member it
belongs to (frame, unit), the attribute (attribute, e.g. "lhv"),
its kind (see SCALE_ATTRIBUTE_KINDS), its value, an optional
lower/upper range, the physical unit_of_measure ("GJ/t",
"kg/TJ"), the source the figure was taken from and an optional note.
Values can be attached at any frame: a calorific value for a whole
carrier is inherited by every fuel under it that has no value of its own
(see scale_attributes()).
attach_attributes_scale(x, attributes, source = NULL, kind = NULL)A NestedScale.
A data.frame with columns frame, unit,
attribute, value, unit_of_measure, and optionally lower,
upper, note; kind and source as columns or through the
arguments.
Optional single string filled into the source column
when attributes has none.
Optional single string filled into the kind column when
attributes has none.
The scale with the rows appended.
Existing rows are never overwritten: a row whose (frame, unit, attribute, source) already exists is an error. Attach a second source
under its own source name and choose between them with source= when
reading.
s <- scale_example()
s2 <- attach_attributes_scale(
s,
data.frame(frame = "class", unit = c("G1", "G2", "S1"),
attribute = "density", value = c(10, 20, 5),
unit_of_measure = "t/m3"),
source = "survey", kind = "property"
)
scale_attributes(s2, "density", frame = "unit")
#> frame unit attribute kind value lower upper unit_of_measure source note
#> 1 unit U1 density property 10 NA NA t/m3 survey <NA>
#> 2 unit U2 density property 10 NA NA t/m3 survey <NA>
#> 3 unit U3 density property 20 NA NA t/m3 survey <NA>
#> 4 unit U4 density property 20 NA NA t/m3 survey <NA>
#> 5 unit U5 density property 5 NA NA t/m3 survey <NA>
#> 6 unit U6 density property 5 NA NA t/m3 survey <NA>
#> 7 unit OTH density <NA> NA NA NA <NA> <NA> <NA>
#> origin_frame origin_unit
#> 1 class G1
#> 2 class G1
#> 3 class G2
#> 4 class G2
#> 5 class S1
#> 6 class S1
#> 7 <NA> <NA>