[R] quotes in cat() within function

Duncan Murdoch murdoch.duncan at gmail.com
Tue Apr 9 23:05:11 CEST 2013


On 13-04-09 6:06 AM, Daniel Caro wrote:
> Hello all,
>
> Sorry if this question has been answered in the past, but I could not find
> an answer.
>
> I am trying to print quotes within a cat output. The arguments are:
>
> file= "Data labels"
> directory= "/home/mylaptop/"
>
> The function returns:
> cat("The file", file, "is located in directory", directory, sep=" ")
>
> The output R prints is
>
> The file Data labels is located in directory /home/mylaptop/
>
> But I want "Data labels" and "/home/mylaptop/" to be in quotation marks.
>
> I find examples using "\", such as
>
> cat("Open fnd \"test\"")
>
> But in my case "test" is an argument.

See ?dQuote.  (Read it carefully:  some people don't like directional 
quotes, and dQuote might give them to you.)

Duncan Murdoch



More information about the R-help mailing list