【问题标题】:list all available symbols in R列出 R 中所有可用的符号
【发布时间】:2022-11-12 13:49:27
【问题描述】:

来自 Plot a heart in R 的以下代码告诉我如何在 R 中绘制红心、梅花、空格和方块。

clubs <- expression(symbol('\247'))
hearts <- expression(symbol('\251'))
diamonds <- expression(symbol('\250'))
spades <- expression(symbol('\252'))
csymbols <- c(clubs, hearts, diamonds, spades)

plot( 0, xlim=c(0,5), ylim=c(0,2), type="n" )
clr <- c("black", "red", "red", "black") 
for (i in 1:4) {
  hline <- function( yloc, ... ) 
         for (i in 1:length(yloc)) 
             lines( c(-1,6), c(yloc[i],yloc[i]), col="gray")  
              hline(0.9); 
                hline(1.0);
                hline(1.1);
                hline(1.2)  
 text( i, 1, csymbols[i], col=clr[i], cex=5 )  
 text( i, 0.5, csymbols[i], col=clr[i] ) }

符号中的帮助列出了更多内容。但是,我想知道如何获取与“\xxx”中不同值对应的整个列表,其中 xxx 是数字。有什么建议么?

为了澄清起见,我正在寻找与不同字符串对应的符号列表。比如上面的'\247'对应梅花,'\252'对应黑桃等等。我正在寻找字符串中这些数字的完整列表。

【问题讨论】:

    标签: r


    【解决方案1】:

    来自?symbol

    符号字体使用 Adob​​e Symbol 编码

    您可以在多个地方找到相关表格。当我搜索时,排名靠前的结果之一托管在 R-Core 会员Paul Murrell's page at the Auckland Statistics Dept

    【讨论】:

      【解决方案2】:

      尝试在 CRAN 上发布的 r2symbols 包,用于在 R 中使用符号。非常喜欢它。

      【讨论】:

        猜你喜欢
        • 2021-04-11
        • 2019-12-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-31
        相关资源
        最近更新 更多