Some packages like expss provide mechanisms for providing longer labels to R objects.
These labels can be used when labeling plots and tables, for example, without requiring
long or awkward variable names. This is an experimental feature and currently only supports
expss or any other system that stores a label in the label
attribute of a vector.
get_labels(object, ...) # S3 method for data.frame get_labels(object, ...) # S3 method for labelled get_labels(object, ...) # S3 method for default get_labels(object, ...) set_labels(object, ...) # S3 method for default set_labels(object, lab = NULL, ...) # S3 method for data.frame set_labels(object, lab = list(), ...) # S3 method for gf_ggplot print(x, lab = get_labels(x$data), ...)
object | An R object, potentially labelled. |
---|---|
... | Additional arguments. Ignored in existing methods. |
lab | A string providing a label (when |
x | A ggplot. |
The label(s) for the object. If object
is a data frame,
labels are extracted from each variable and returned as a named list.
If there are no labels, NULL
is returned.
KF <- mosaicData::KidsFeet %>% set_labels( length = 'foot length (cm)', width = 'foot width (cm)', birthmonth = 'birth month', birthyear = 'birth year', biggerfoot = 'bigger foot', domhand = 'dominant hand' ) KF %>% gf_point(length ~ width, color = ~ domhand)get_labels(KF)#> $name #> NULL #> #> $birthmonth #> [1] "birth month" #> #> $birthyear #> [1] "birth year" #> #> $length #> [1] "foot length (cm)" #> #> $width #> [1] "foot width (cm)" #> #> $sex #> NULL #> #> $biggerfoot #> [1] "bigger foot" #> #> $domhand #> [1] "dominant hand" #>