# new DTSg object
x <- DTSg$new(values = flow)
# cap river flows to 100
## R6 method
x$setCols(
i = flow > 100,
cols = "flow",
values = 100
)$print()
## 'set()' is a "hidden" R6 alias for 'setCols()'
x$set(
i = flow > 100,
cols = "flow",
values = 100
)$print()
## S3 method
print(setCols(
x = x,
i = flow > 100,
cols = "flow",
values = 100
))
# set measurement unit with the help of 'units'
if (requireNamespace("units", quietly = TRUE)) {
## R6 method
x$setCols(
cols = "flow",
values = units::set_units(x["flow"], "m^3/s")
)$print()
## S3 method
print(setCols(
x = x,
cols = "flow",
values = units::set_units(x["flow"], "m^3/s")
))
}
Run the code above in your browser using DataLab