axis_labs: Apply labels from variables to axis-labels in plots.

View source: R/plot_functions.R

axis_labsR Documentation

Apply labels from variables to axis-labels in plots.

Description

axis_labs takes labels from labelled data to use them as axis-labels for plots generated by gformula or ggplot2.

Usage

axis_labs(object)

Arguments

object

ggplot2 object (see examples).

Details

This functions is helpful when data has been already labelled by sjlabelled. It retrives variable labels and use them for plotting.

Value

A ggplot2 object.

Examples

data(kfm, package = "ISwR")
require(sjlabelled, quietly = TRUE)
kfm <- kfm |>
  var_labels(
    dl.milk = "Breast-milk intake (dl/day)",
    sex = "Sex",
    weight = "Child weight (kg)",
    ml.suppl = "Milk substitute (ml/day)",
    mat.weight = "Maternal weight (kg)",
    mat.height = "Maternal height (cm)"
  )

kfm |>
  gf_point(weight ~ dl.milk) |>
  gf_lm(col = 2, interval = "confidence", col = 2) |>
  axis_labs()

kfm |>
  box_plot(dl.milk ~ sex, fill = "thistle", alpha = 0.8) |>
  axis_labs() |>
  gf_star(x1 = 1, y1 = 10.9, x2 = 2, y2 = 11, y3 = 11.2)

pubh documentation built on Oct. 8, 2024, 9:08 a.m.