Can R paste() output “\”?

后端 未结 3 1250
一整个雨季
一整个雨季 2020-12-18 10:41

As stated in the Intro to R manual,

paste(\"\\\\\")

prints

[1] \"\\\\\"

Is it possible for paste to prin

3条回答
  •  北海茫月
    2020-12-18 11:14

    You are confusing how something is stored and how it "prints".

    You can use paste to combine a \ with something else, but if you print it then the printed representation will have \ to escape the \, but if you output it to a file or the screen using cat instead, then you get the single \, for example:

    > tmp <- paste( "\\", "cite{", sep="" )
    > print(tmp)
    [1] "\\cite{"
    > cat(tmp, "\n")
    \cite{ 
    

提交回复
热议问题