Can I escape characters in variable names?

后端 未结 1 1629
迷失自我
迷失自我 2020-12-16 02:42

Sometimes it would be useful to name variables like no programmer should name his or her variables. Of course there\'s some good reason for conventions and limitations on st

相关标签:
1条回答
  • 2020-12-16 03:32

    You can use backticks:

    R> `a + b` <- 3
    R> `a + b`
    [1] 3
    
    tmp <- data.frame(1:10, rnorm(10))
    names(tmp) <- c("a+b", "c&d")
    ggplot(tmp, aes(`a+b`, `c&d`)) + geom_point()
    

    See also ?Quotes.

    0 讨论(0)
提交回复
热议问题