【问题标题】:"smaller or equal" sign in main item for the plot function in rr中绘图功能的主要项目中的“小于或等于”符号
【发布时间】:2019-05-30 16:52:26
【问题描述】:

我想使用表达式或 bquote 在情节的主要部分使用“小于或等于” (≤) 符号。

很遗憾,我的代码出错了。

错误:"bq.FWGroup 中出现意外的 '

你能帮我解决这个问题吗?

FWGroup<-c("20cm <= Length < 30cm, 175g <= Weigth < 225g","20cm <= Length < 30cm, 225g <= Weigth < 275g",
           "30cm <= Length < 40cm, 200g <= Weigth < 250g","30cm <= Length < 50cm, 250g <= Weigth <= 300g")
Köder<-c("lebend","Atrappe")    

Versuche<-c(7,3,6,8,6,12,5)
Versuche<-cbind(Versuche,c(3,8,2,1,7,4,9))   
Group<-c(1,1,2,1,4,2,3)   
#for (i in 1:4)  {
# for (j in 1:2) {
i<-1; j<-1  
plot(1:7,Versuche[,1],
     type="n",
     main=paste(FWGroup[i],"Koeder:",Koeder[j],"_______________")) 
#bquote: 
bq.FWGroup<-c(bquote("20cm "~ <= ~" Length < 30cm, 175g" ~ <= ~ "Weigth < 225g"),bquote("20cm <= Length < 30cm, 225g <= Weigth < 275g"),bquote("30cm <= Length < 40cm, 200g <= Weigth < 250g"),bquote("30cm <= Length < 50cm, 250g <= Weigth <= 300g"))


plot(1:7,Versuche[,1],
     type="n",
     main=paste(bq.FWGroup[i],"Koeder:",Koeder[j],"_______________"))  

#exqpression:  
ex.FWGroup<-c(paste("20cm ", expression(<=), " Length < 30cm, 175g", expression(<=) , "Weigth < 225g"),"20cm <= Length < 30cm, 225g <= Weigth < 275g","30cm <= Length < 40cm, 200g <= Weigt < 250g","30cm <= Length < 50cm, 250g <= Weigth <= 300g")

ex.FWGroup<-c( expression(paste("20cm ", <=, " Length < 30cm, 175g", <= , "Weigth < 225g")),"20cm <= Length < 30cm, 225g <= Weigth < 275g", "30cm <= Length < 40cm, 200g <= Weigth < 250g","30cm <= Length < 50cm, 250g <= Weigth <= 300g")

plot(1:7,Versuche[,1],
     type="n",
     main=paste(ex.FWGroup[i],"Koeder:",Koeder[j],"_______________"))  
#  }
#  }

【问题讨论】:

    标签: r plot expression


    【解决方案1】:

    R 可识别 Unicode 字符,因此只需在标题中写入相应的值即可。

    plot(iris$Sepal.Width ~ iris$Species, main = "3 \u2264 5")
    

    Main Title with ≤

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 2021-12-29
      • 2020-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多