I'm trying to do a barplot where entries of the same factor are next to eachother so I can compare (in this example I want to compare the tissue type).
I sort the dataframe but for some reason ggplot does not follow the sorting.
tp <- ms %>%
arrange(tissue) %>%
mutate(tissue=as.factor(tissue))
ggplot(tp) +
geom_bar(aes(x=Sample, y=!!sym(cv), fill=tissue), stat="identity") +
ylab("")
head(tp$tissue)
and I check and i know that tp
is sorted
head(tp$tissue)
outputs
[1] adjacent adjacent adjacent adjacent adjacent adjacent
Levels: adjacent normal tumor