简体   繁体   English

使用表达式在R中的group.names中添加希腊字母

[英]Using expression to add Greek letters to group.names in R

I am trying to rename the group names in a stripchart. 我正在尝试在带状图中重命名组名。 I have tried using bquote and expression, but ran into the same problem. 我尝试使用bquote和expression,但是遇到了同样的问题。 Everything within the brackets following expression is printed as a group label without formatting (so in the example below I am getting a label that reads "Delta ~ "Group1"". 表达式后方括号内的所有内容都作为组标签打印而没有格式化(因此在下面的示例中,我得到的标签为“ Delta〜“ Group1””。

I've tried combining expression and paste, but that gave me a label that read "paste(Delta, "Group1")". 我曾尝试将表达式和粘贴结合起来,但这给了我一个标签,上面写着“ paste(Delta,“ Group1”)“。

stripchart(Df$value~Df$Treatment , 
    vertical = TRUE,
    group.names = c(expression(Delta ~ "Group1"), "Group2"),

Try setting your group.names=NA and then using the axis command to add the group.names afterwards. 尝试设置您的group.names = NA,然后使用axis命令随后添加group.names。

I couldn't reproduce your example but if you do something like: 我无法复制您的示例,但是如果您执行以下操作:

## define what you want your group.names to be using expression     
group_names=c(expression(Delta==1),expression(Delta==2),expression(Delta==3),expression(Delta==4),expression(Delta==5))

## make your strip chart
stripchart(Temp~Month, data=airquality,group.names=NA,vertical=TRUE)

## add the lower axis labels, which equivalently adds the group.names
axis(1,at=1:5,labels=group_names)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM