[Solved] How can the facet function in ggplot be used to create a histogram in order to visualize distributions for all variables in a dataset?


I’ve copied the data from your post above so you can skip the variable assignment

library("tidyverse")

df <- read.table(file = "clipboard", header = T) %>% 
  as_tibble()

You need to modify your data structure slightly before you pass it to ggplot. Get each of your test names into a single variable with tidyr::gather. Then pipe to ggplot:

df %>% 
  gather(test, value, -id) %>% 
  ggplot(aes(x = value)) +
  geom_histogram() +
  facet_grid(~test)

solved How can the facet function in ggplot be used to create a histogram in order to visualize distributions for all variables in a dataset?