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


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

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() +

Browse More Popular Posts

Leave a Comment