3 Compact letter display(CLD) three way ANOVA and visualisation with R and ggplot2 part III
ฝัง
- เผยแพร่เมื่อ 6 ต.ค. 2024
- #rprogramming #rprogramming #anovaplot #ggplot2 #emmeans #cld #compactletterdisplay
In this tutorial, you will learn how to effectively apply Three-Way ANOVA to analyze your data and then compute the Critical Difference (CLD) values. We will dive into the world of R programming and utilize the powerful ggplot2 library to create stunning visualizations of the CLD results. Join us to unlock the secrets of statistical analysis and take your data interpretation skills to the next level!
This is a 3 part video tutorial
part 1 : one way ANOVA and CLD : • I - Compact Letter Dis...
part 2: Two way Anova and CLD : • 2 Compact letter displ...
part 3: Three way Anova and CLD : • 3 Compact letter displ...
code
compact letter display using ggplot2
library(palmerpenguins)
library(emmeans)
library(multcomp)
convert to data frame
penguins= as.data.frame(penguins)
head(penguins)
mod3 = aov(flipper_length_mm~species+ island+sex, penguins)
summary(mod3)
emmean = emmeans(mod3,specs = c("species","island","sex"))
emmean_cld = cld(emmean,Letters=letters)
library(ggplot2)
library(ggpattern)
p = ggplot(emmean_cld,aes(species,emmean,fill=island,pattern=sex,label=.group))+
geom_col_pattern(position="dodge", alpha=0.5, color="grey60",
pattern_fill="black",
pattern_density=0.1,
pattern_angle=45,
pattern_spacing=0.025,
pattern_key_scale_factor=0.6)+
geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE),
width=0.2,
size=0.75,
position=position_dodge(width=0.9))+
geom_text(position=position_dodge2(width=0.9),vjust=-0.5,size=4)+
theme_classic()+
theme(legend.position = "bottom")
ggsave("Three way anova with cld.png",p, width=9, height=5, units="in")
with theme pubr
p = ggplot(emmean_cld,aes(species,emmean,fill=island,pattern=sex, label=.group))+
geom_col_pattern(alpha=0.5,color="grey20",
position = "dodge",
pattern_fill = "black",
pattern_angle = 45,
pattern_density = 0.1,
pattern_spacing = 0.025,
pattern_key_scale_factor = 0.6)+
#scale_pattern_manual(values = c(Nerd = "stripe", NotNerd = "none"))+
geom_errorbar(aes(ymin=emmean-SE,ymax=emmean+SE),
position = position_dodge(width=0.9), width=0.3,size=0.5)+
geom_text(position = position_dodge2(width=0.9),vjust=-0.5,size=4)+
guides(pattern = guide_legend(override.aes = list(fill = "white")),
fill = guide_legend(override.aes = list(pattern = "none")))+
theme_pubr()
ggsave("AOV_plot.png",p,width=7,height=4,units="in")
Facebook page:
/ rajendrachoureisc
Mail Id:
rajuchoure@gmail.com
youtube playlist:
• R programming tutorials