Learn R Programming

pubh (version 3.0.0)

effect_plot: Constructs effect plots on for cases when the response (outcome) is a numerical variable and the explanatory (exposure) is a categorical variable.

Description

effect_plot constructs plots with error bars on which the upper and lower limits of the bars are given by the variables CI_high and CI_low, respectively.

Usage

effect_plot(data, x, y, orientation = "x")

Value

An error bars plot, for example, those to show the effects of a categorical variable on a numerical variable.

Arguments

data

A data frame.

x

A variable in the data frame.

y

A variable in the data frame.

orientation

A string indicating the orientation of the bars.

Examples

Run this code
data(Fentress)
require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)

pain_cis <- Fentress |>
  gen_bst_df(pain ~ group)
names(pain_cis)[1] = "Mean"
pain_cis = pain_cis |>
  var_labels(Mean = "Pain reduction")

pain_cis |>
  effect_plot(x = Cohort, y = Mean)

Run the code above in your browser using DataLab