Yes, it's meant to be a string. Your code works, but the µlog isn't my title, it's just a label, which is placed over each boxplot:
Here is my code again for the full plot:
library(dplyr)
library(ggplot2)
dv <- c(1.,0.5,0.9,2,4,1,0.3,4,0.1,3)
dv_log <- log10(dv)
iv <- c(1,2,2,1,3,2,1,3,2,3)
dat <- data.frame(dv,dv_log,iv)
dat <- mutate(dat,dv_kat = cut(dv,breaks = c(0,0.3,0.5,0.7,0.9,1.12,1.43,2.01,3.31,105),labels = c("5","4","3","2","1","2","3","4","5")))
text_labels1 <- group_by(
dat %>% drop_na(dv_kat, iv, dv),
iv
) %>% summarise(
textlabel = paste(
"n =", format(n(), big.mark = " ",justify = "left"),
"\n",
expression("µ"['log'])," = ", sprintf('%.2f',mean(dv_log),justify = "left")
),
y=200
)
# plotten
ggplot(dat,mapping = aes(
x = as.numeric(iv),
y = dv
)) +
geom_text(
data = text_labels1,
aes(label = textlabel,color=NULL,
y=y),show.legend = FALSE,size=2.5
) +
geom_hline(yintercept = 1e+00,linetype="dotted")+ # horizontale Linie zeigt die 100%ige Übereinstimmung der Zugangszeiten an
geom_jitter(position=position_jitter(0.25),aes(color = factor(dv_kat)), alpha=0.6)+
stat_boxplot(aes(group=iv),geom ='errorbar',width=0.25)+
geom_boxplot(aes(group=iv),outlier.color = "transparent",fill="transparent") +
scale_color_manual(values = c("red4", "red3", "orange", "green3", "green4"), labels = c("sehr schlecht", "schlecht", "mäßig", "gut", "sehr gut"),guide = guide_legend(shape = c(rep(16, 7), NA, NA))) +
scale_x_continuous(breaks = 1:3, name = "IV", labels = c("1", "2", "3")) +
scale_y_continuous(trans='log10', limits = c(0.006,200))+
scale_fill_manual(breaks = 1:3, name = "IV", labels = c("1", "2", "3")) +
labs(x = "IV",
y = "XYZ-Fakt [log]",
color = "XYZ:") +
theme_bw()+
theme(legend.position = "bottom",legend.background = element_rect(color = "black",fill = "transparent"),legend.key.size = unit(0.3,"cm"))
Hope, I made it clearer now.