Reorder Boxplot in Base R & ggplot2 (2 Examples) | Change Ordering | Reorder Factor Levels of Data

preview_player
Показать описание
R code of this video:

values = rnorm(100))

boxplot(data$values ~ data$group) # Default boxplot in Base R

data_new <- data # Duplicate data
data_new$group <- factor(data_new$group, # Reorder factor levels
c("C", "B", "D", "A"))

boxplot(data_new$values ~ data_new$group) # Reordered boxplot in Base R

library("ggplot2")

ggplot(data_new, aes(group, values)) + # Reordered boxplot in ggplot2
geom_boxplot()

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

Dang you came to my rescue twice within 24 hr! Thanks for the great videos!!

kydaviddoyle
Автор

Very well explained and useful. Great pace.

franciscobarillas
Автор

Quick, easy and excellent explanation. Thank you

emmettetaylor
Автор

I like the new layout, Joachim, I find it mich more personal.

agsoutas
Автор

Why is it that when I try to reorder my factors R converts all of them to NA's?

pertinaciousD
Автор

Thanks for the tutorial! Very helpful!

nicolabiondi
Автор

Nice video, but how to I order e. g. the box plots according to their median, when I have for example only headers with plant species (which are shown on the x asis, like the data A, B, C, ... in your video) and measurements per plot for the y axis, I cant figure out how to do it when there is more than two colums and too much data to write the collum names so I would determine their order manually

dmewgge
Автор

Hi! Thanks for making it easy for us to learn R. I have a doubt. If I have directly imported my data set, how can I then change the order of the boxplots? Thanks

eshitab
Автор

Thanks for the tutorial!
If we had more levels per factor ("letters" in the x axis), such as "A-left, B-left, A-right, B-right" and so on, how could we reorder them all? In this example, they should be shown as "A-left, A-right, B-left, B-right" etc. My dataset was designed for a ANOVA two-way. Is it possible to do that with base R, not ggplot ? Thank you!

matosleni
welcome to shbcf.ru