This function changes the labels
of a safeframe
object, using the same
syntax as the constructor make_safeframe()
.
Arguments
- x
a
data.frame
or atibble
- ...
<
dynamic-dots
> A named list with variable names inx
as list names and the labels as list values. Values set toNULL
remove the label. When specifying labels, please also seedefault_values
.
See also
make_safeframe()
to create a safeframe
object
Examples
## create a safeframe
x <- make_safeframe(cars, speed = "Miles per hour")
labels(x)
#> $speed
#> [1] "Miles per hour"
#>
## add new labels and fix an existing one
x <- set_labels(x, dist = "Distance")
labels(x)
#> $speed
#> [1] "Miles per hour"
#>
#> $dist
#> [1] "Distance"
#>
## remove labels by setting them to NULL
old_labels <- labels(x)
x <- set_labels(x, speed = NULL, dist = NULL)
labels(x)
#> $speed
#> [1] ""
#>
#> $dist
#> [1] ""
#>
## setting labels providing a list (used to restore old labels here)
x <- set_labels(x, !!!old_labels)
labels(x)
#> $speed
#> [1] "Miles per hour"
#>
#> $dist
#> [1] "Distance"
#>