Размещение меток CLD над панелями ошибок в gpplot boxplot, должно быть простым, но - PullRequest
0 голосов
/ 05 марта 2020

Я очень плохо знаком с R (начал играть с ним в понедельник), и я могу сделать некоторые базовые c вещи, однако, я не могу показать, что могу маркировать свои ящики в моем боксплоте с дисплеем CLD , Я знаю, как генерировать метки, с помощью теста Tukey post-ho c, и я знаю, что каким-то образом этого можно достичь с помощью geom_text. Но я не могу понять это, я хотел бы помочь. Я включил свой сценарий с некоторыми комментариями, объясняющими, что и почему я сделал. Я также добавил сюжет, который у меня сейчас есть. заранее спасибо

library(readr)
library(multcomp)
library(ggplot2)
library(tidyverse)
library(extrafont)
library(agricolae)
library(multcompView)
library(forcats)
library(gapminder)
#load in my data (I made a CSV file in excell, it shows 4 treatments and then the dry weight for each >sample for these treatments)
dryweightarabidopsis <- read_csv("blahblahmydata.csv")
#show the data
View(dryweightarabidopsis)
#set this data as my data frame
df=dryweightarabidopsis
#make a boxplot with my dataframe, order the x axis in descending order, add errorbars with wiskers and colour boxes by treatment.
p <- ggplot(df, aes(x=fct_reorder(treatment,dw,.desc = TRUE), y=dw, fill=treatment)) + stat_boxplot(geom = "errorbar", width=.2) + geom_boxplot()
#add some asthetic elements
p <- p +scale_fill_brewer(palette = "Pastel1") + theme(panel.grid.major = element_blank(), >panel.grid.minor = element_blank()) + theme(panel.background = element_blank())
#name x and y axis and move the titles slightly away from the axis
p <- p+ xlab("\ntreatment") + ylab("dry shoot weight (gram)\n")
#again some asthetics stuff, change font and add data points
p <- p + theme(text = element_text(family = "Times New Roman")) + geom_jitter(width = 0.1, alpha = 0.2)
#print the plot
p
#name the grouping variable as factor, otherwise my multiple comparison wont work later on
df$treatment=as.factor(df$treatment)
#Run ANOVA
res.aov <- aov(dw ~ treatment, data=df)
#Run tukey post hoc test
res.tukey <- summary(glht(res.aov, mcp(treatment = "Tukey")))
#show the CLD display of the post hoc test
cld(res.tukey)

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...