R 刻面标签中使用希腊字符的等号的多行-ggplot2

R 刻面标签中使用希腊字符的等号的多行-ggplot2,r,ggplot2,facet,R,Ggplot2,Facet,我试图在刻面网格图中使用希腊字符equalities标记我的刻面,在两个equalities之间有一个换行符 我用于生成此文件的代码如下所示: set.seed(1) outtown<-cbind(rep(1,100),runif(100,-100,100),runif(100,-100,100),rep(1,100)) colnames(outtown)<-c('hh_id','x','y','z') outtown[,1]<-print(paste("alpha==",

我试图在刻面网格图中使用希腊字符equalities标记我的刻面,在两个equalities之间有一个换行符

我用于生成此文件的代码如下所示:

set.seed(1)  
outtown<-cbind(rep(1,100),runif(100,-100,100),runif(100,-100,100),rep(1,100))
colnames(outtown)<-c('hh_id','x','y','z')
outtown[,1]<-print(paste("alpha==",100,"\n beta==",200,sep=""))  
outtown<-data.frame(outtown) 
outtown[,1]<-as.factor(outtown[,1])  
outtown[,2]<-as.numeric(as.character(outtown[,2]))  
outtown[,3]<-as.numeric(as.character(outtown[,3]))  
outtown[,4]<-as.factor(outtown[,4])  
str(outtown)

library(ggplot2) 
ev <- ggplot(outtown, aes(x = outtown[,2], y = outtown[,3])) +
  geom_boxplot(mapping=aes(x=outtown[,2],y=outtown[,3],shape=1,colour=outtown[,1]),outlier.size = 0.5,lwd=0.3) +
  scale_shape_identity() +
  theme(axis.text.x=element_text(angle = 45, hjust = 1,size=5))

ev + facet_grid(z~hh_id,scale='free',labeller=label_parsed)+
  xlab("Estimator") +
  ylab("Bias") +
  scale_color_discrete(name='Type of\nEstimator')
set.seed(1)

outtown我有一个类似的问题,发现@plannapus的答案如下:

可以使用top()来解决这个问题

set.seed(1)  

outtown <- data.frame(hh_id = rep(1,100), 
           x = runif(100,-100,100), 
           y = runif(100,-100,100), 
           z  = rep(1,100))

outtown$hh_id <- "atop(alpha==100, beta==200)"

library(ggplot2) 
ev <- ggplot(outtown, aes(x = x, y = y)) +
  geom_boxplot(mapping=aes(x=x,y=y,shape=1, group = hh_id),outlier.size = 0.5,lwd=0.3) +
  scale_shape_identity() +
  theme(axis.text.x=element_text(angle = 45, hjust = 1,size=5))

ev + facet_grid(z~hh_id,scale='free',labeller=label_parsed)+
  xlab("Estimator") +
  ylab("Bias") 

set.seed(1)

outtown
outtown[,1]@HubertL在代码的这一部分,我只是在玩函数。这部分只是用来标记刻面。我同意,本可以更优雅地处理它。您应该在
aes
中使用变量名,因此
aes(x=x,y=y)