Search code examples
rstringconcatenationsingle-quotes

Add single quotes to a string


I try to add single quotes to a string but don't see how to do it. For instance I would like to replace ABC by 'ABC'.

I have played with paste, cat, print but don't see how to do it.

Any solution?

Thanks, Vincent


Solution

  • Just use paste:

    R> paste("'", "ABC", "'", sep="")
    [1] "'ABC'"
    

    or the new variety

    R> paste0("'", "ABC", "'")
    [1] "'ABC'"