在ggboxplot中使用下标

我正在尝试绘制一些数据,我的一个实验组名为SiO 2。我使用read.table加载.txt数据表,然后使用colnames()

colnames(cells_df2) <- c("ID","Ctrl","SiO\u2082","pSLG","fSLG")

这是我的数据的子集。

head(cells_df2)
ID     Ctrl  SiO2     pSLG     fSLG
1  1  5.68565  9.48 14.77580 33.04500
2  2  6.79996 32.00 14.35580 33.04500
3  3 21.77180  8.14 16.49780  7.61765
4  4 16.30750  8.14  1.87977  7.61765
5  5 11.16920 19.20  5.54189 28.47990
6  6 11.31430  8.26 15.59490 28.47990

然后,我gather将此数据.frame

Cells_tidy3<-gather(cells_df2,"group","ym",-ID)
  ID group       ym
1  1  Ctrl  5.68565
2  2  Ctrl  6.79996
3  3  Ctrl 21.77180
4  4  Ctrl 16.30750
5  5  Ctrl 11.16920
6  6  Ctrl 11.31430

最后我将它们绘制出来

ggboxplot(Cells_tidy3,"ym")

在ggboxplot中使用下标

我尝试使用expressionparsestringi软件包,但结果很少。

如果我要capabilities()

jpeg         png        tiff       tcltk         X11        aqua    http/ftp 

TRUE        TRUE        TRUE        TRUE       FALSE       FALSE`    TRUE 

sockets      libxml        fifo      cledit       iconv         NLS   profmem

TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE

cairo         ICU long.double     libcurl 

TRUE        TRUE        TRUE        TRUE 

然后我尝试:

png()
ggplot(az,aes(x = "SiO\u2082",y = value)) + 
geom_boxplot() +
xlab("")
dev.off()

导致该图的人

在ggboxplot中使用下标

wxw111 回答:在ggboxplot中使用下标

以下作品。它使用ggplot后跟geom_boxplot,而不是ggpubr::ggboxplot

library(ggplot2)

az <- subset(iris[5:4],Species == "virginica")
az[[1]] <- droplevels(az[[1]])
names(az) <-c("SiO\u2082","value")

ggplot(az,aes(x = "SiO\u2082",y = value)) + 
  geom_boxplot() +
  xlab("")

enter image description here

对于软件包ggpubr,问题在于您如何gather编辑数据。列"value"成为一列,其值是az中先前列名的值,即"ciao"

library(tidyr)
library(ggpubr)

azz <- az %>% gather(group,key,-value)
ggboxplot(azz,x = "group",y = "value")

enter image description here

本文链接:https://www.f2er.com/2957060.html

大家都在问