data

To work outside of this tutorial you need to download the following data file:

Set up an r rstudio() project in the way that I recommend in this video, and save the data files to the folder within your project called [data]{.alt}. Place this code in the first code chunk in your r quarto() document:

cosmetic_tib <- here::here("data/cosmetic.csv") |>
  read_csv() |>
    mutate(
      clinic = as_factor(clinic) |> fct_relevel(paste("Clinic", seq(1, 20, 1))),
      reason = as_factor(reason) |> fct_relevel("Change appearance")
  )

This code reads in the data and converts the variables reason and clinic to factors (categorical variable). It uses fct_relevel to set the order of the levels of the factor reason to be change appearance and physical reason, and to set the levels of the factor clinic to be Clinic 1, Clinic 2 ... Clinic 10 in numeric order (try executing the code paste("Clinic", seq(1, 10, 1)) and you'll see it pastes the text "Clinic " to the numbers 1 to 10 in turn).



Try the discovr package in your browser

Any scripts or data that you put into this service are public.

discovr documentation built on Feb. 5, 2026, 5:07 p.m.