changing the order of graphs using facet_nested_wrap

45 views Asked by At

I have a set of data that I wanted to split by two variables, the first being "genome" the second being "Clade". I want each row to have graphs of the same "genome" (which include Dniva, Echei, Iindi and Mpgym) and each row to be "Clade". the issue is that each genome doesnt have the same number of Clades in it. so some rows might have 2 columns others maybe 5. is there a way to organise them in this way?

#this is my code so far

ggplot(LTR_Gypsy_CodingDomains_3, aes(y = CodingDomains, x = Number)) + 
  geom_col(fill = "#669933", color = "black") +
  facet_nested_wrap(vars(genome, Clade), bleed = TRUE, scales = "free_y") +
  theme(axis.text.y = element_text(size = 5), axis.text.x = element_text(size = 5), strip.text =     element_text(size = 6, margin = margin()))

#it produced the graphs below

enter image description here

as you can see some of the genomes are spread across two rows. how can i make it so that each genome is on its own row.

I am very new to this so please let me know if I've made any mistakes!

0

There are 0 answers