从 R 列表名称中删除重音符号 (`)

标签 r naming-conventions

我有一个列表l,它在输出中具有重音符号“`”。为什么我在某些变量中得到这个,而在其他变量中却没有?

l
    $`AMLM12PAH037A-B`

             Left.Gene.Symbols Right.Gene.Symbols
      PCMTD1                 0                  1
      STK31                  3                  0

    $AMLOT120AT

              Left.Gene.Symbols Right.Gene.Symbols
      ARHGEF3                 2                  0
      CD96                    2                  0
      RALYL                  12                  0
      TRIO                    0                  1

最佳答案

不能有无效的名称,在本例中,它是其中的 - 。如果这样做,您要么会像您的那样被反引号转换,要么会出现错误,具体取决于您的制作方式。

除其他限制外,您还不能以数字开头名称。

查看函数 check.namesmake.names

来自R FAQ :

  • A syntactic name is a string the parser interprets as this type of expression. It consists of letters, numbers, and the dot and (for
    versions of R at least 1.9.0) underscore characters, and starts with
    either a letter or a dot not followed by a number. Reserved words are not syntactic names.

  • An object name is a string associated with an object that is assigned in an expression either by having the object name on the left of an assignment operation or as an argument to the assign() function. It is usually a syntactic name as well, but can be any non-empty string if it is quoted (and it is always quoted in the
    call to assign()).

  • An argument name is what appears to the left of the equals sign when supplying an argument in a function call (for example, f(trim=.5)). Argument names are also usually syntactic names, but again can be anything if they are quoted.
  • An element name is a string that identifies a piece of an object (a component of a list, for example.) When it is used on the right of the ‘$’ operator, it must be a syntactic name, or quoted. Otherwise, element names can be any strings. (When an object is used as a database, as in a call to eval() or attach(), the element names become object names.)

关于从 R 列表名称中删除重音符号 (`),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34224355/

相关文章:

r - 表格包括使用 ANOVA 的 3+ 组的组间 p 值比较

css - 如何使用 BEM 正确设置元素的范围?

javascript - 何时使用 `parent` 以及何时使用 `root` 作为 GraphQL 解析器函数中的第一个参数

根据命名约定,带有 "has"前缀的 Java boolean setter

r - 不属于同一组的点到该点的最近邻距离

r - 确定数据输入的重要子组

r - PCA FactoMineR 绘图数据

javascript - 如何在我的 Rmarkdown html 输出中获取复制按钮,以将 R 代码中生成的表格复制到剪贴板?

HTML5 标签名称约定 - 自定义标签和破折号的使用

c - C中的函数命名 : parentheses in function names