set_var_labels.RdSet variable labels for a data frame using name-label pairs.
set_var_labels(data, ...)If no label is provided for a variable then the existing label will not be changed. To remove a label set the label to NA.
set_labels() for setting variable labels using a data frame,
extract_labels() for creating a data frame of all variable labels,
clear_labels() for removing variable labels
# set labels using name-label pairs
# and return labelled data frame
data("ctDNA")
ctDNA |> set_var_labels(
ctdna_status="detectable ctDNA",
cohort="A cohort label")
#> # A tibble: 270 × 5
#> id cohort ctdna_status time size_change
#> <chr> <fct> <fct> <dbl> <dbl>
#> 1 INS-A-002 A No clearance, increase from baseline 8.12 5.7
#> 2 INS-A-002 A No clearance, increase from baseline 12.4 NA
#> 3 INS-A-003 A No clearance, increase from baseline 6.12 41.7
#> 4 INS-A-007 A No clearance, decrease from baseline 8.83 -45.5
#> 5 INS-A-007 A No clearance, decrease from baseline 16.8 -72.7
#> 6 INS-A-007 A No clearance, decrease from baseline 25.8 -63.6
#> 7 INS-A-007 A No clearance, decrease from baseline 37.0 -54.5
#> 8 INS-A-007 A No clearance, decrease from baseline 43.3 -54.5
#> 9 INS-A-007 A No clearance, decrease from baseline 49.0 -100
#> 10 INS-A-007 A No clearance, decrease from baseline 60.0 -100
#> # ℹ 260 more rows