pubh (version 1.1.16)

axis_labs: 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).

Value

A ggplot2 object.

Details

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

Examples

Run this code
# NOT RUN {
data(kfm, package = "ISwR")
require(sjlabelled)
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)
# }

Run the code above in your browser using DataCamp Workspace