Send a text string containing double quotes to function

前端 未结 2 1261
遇见更好的自我
遇见更好的自我 2020-12-10 08:05

I\'m having a problem with using double quotes while formatting text strings being sent to functions in R.

Consider an example function code:

foo <         


        
2条回答
  •  不知归路
    2020-12-10 08:37

    Two ways I know. First is to just use single quotes to start and end the character string:

    > cat( 'Learning "R" is fun!' )
    Learning "R" is fun!
    

    Second is to escape the double quotes:

    > cat( "Learning \"R\" is fun!" )
    Learning "R" is fun!
    

    Note that this works because I use cat, which is intended to output strings to the console. It seems you use print() which shows the object rather than output it

提交回复
热议问题