Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 按特定顺序部分斜体化的刻面标题_R_Ggplot2 - Fatal编程技术网

R 按特定顺序部分斜体化的刻面标题

R 按特定顺序部分斜体化的刻面标题,r,ggplot2,R,Ggplot2,我试图在ggplot2中获得部分斜体化的方面标题。我希望面按特定顺序排列,我使用facet\u grid(~factor(YSD,levels=c('465','466','1572')指定该顺序。 这是我的数据的标题 > head(df) YSD Media OD Replicate 1 465 - Met 1.790500 1 2 465 - Met 1.616300 1 3 465 - Met 1.745700 1 4

我试图在
ggplot2
中获得部分斜体化的方面标题。我希望面按特定顺序排列,我使用
facet\u grid(~factor(YSD,levels=c('465','466','1572')指定该顺序。

这是我的数据的
标题

> head(df)
  YSD Media       OD Replicate
1 465 - Met 1.790500         1
2 465 - Met 1.616300         1
3 465 - Met 1.745700         1
4 465 - Met 2.439433         1
5 465 - Met 2.070033         1
6 465 - Met 2.192433         1

> dput(df[1:10,])
structure(list(
YSD = c("465", "465", "465", "465", "465", "465", "465", "465", "465", 
"465"), 
Media = c("- Met", "- Met", "- Met", "- Met", "- Met", "- Met", "30 µM 
Met", "30 µM Met", "30 µM Met", "30 µM Met"), 
OD = c(1.7905, 1.6163, 1.7457, 2.439433, 2.070033, 2.192433, 1.9288, 
1.5506, 1.5966, 2.204833), 
Replicate = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), 
row.names = c(NA, 10L), 
class = "data.frame")
这是我的代码:

df <- read.csv("37C all.txt", sep="\t", check.names=FALSE)
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")

my_labels <- c(expression(paste(italic("C. glabrata"), "CBS138")),
           expression(paste(italic("C. glabrata "), Delta, "HTL")),
           expression(paste(italic("Met3p-Hsp90"))))

df$YSD <- as.character(df$YSD)

dplot <- ggplot(data = df, aes(x = Media, y = OD, fill = YSD)) +
geom_boxplot(outlier.colour = "white") +
geom_dotplot(binaxis='y', stackdir='center', dotsize=0.5, binwidth = NULL) +
facet_grid(~factor(YSD, levels = c('465', '466', '1572'), labels = my_labels)) +
scale_y_continuous(limits = c(0, 3.0)) +
scale_x_discrete(limits=c("- Met", "30 µM Met", "40 µM Met", "DMSO", "50 µM Radicicol")) +
theme(axis.text = element_text(size=12), axis.title = element_text(size=12)) +
theme_bw() +
theme(axis.text.x = element_text(angle = 80, vjust = 0.5)) +
theme(legend.position = "none") + 
labs(title = "37°C Adhesion") 
但我得到了错误信息:

Error in levels(df$YSD) = c(`465` = expression(paste(italic("C. glabrata"),  : 
  unimplemented type 'expression' in 'HashTableSetup'

非常感谢您提供的任何帮助。谢谢。

查看哪些解决类似问题的方法。请共享数据示例,例如
dput(df)
的输出,或者如果太长,
dput(df[1:10,])
。否则,我们每个人都必须尽最大努力制作类似于您的数据来测试解决方案,而不知道它是否真的与您的一样。我编辑了我的原始帖子,以显示我的数据样本。@RichardTelford,您的物种斜体练习者是否会选择第三个方面的名称,这不是物种名称?
Error in levels(df$YSD) = c(`465` = expression(paste(italic("C. glabrata"),  : 
  unimplemented type 'expression' in 'HashTableSetup'