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. Thank you Daniel [[alternative HTML version deleted]]
Try: directory= "\"/home/mylaptop/\"" Hope this helps, Adrian On Tue, Apr 9, 2013 at 1:06 PM, Daniel Caro <dcarov@gmail.com> 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. > > > Thank you > > Daniel > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd. 050025 Bucharest sector 5 Romania Tel.:+40 21 3126618 \ +40 21 3120210 / int.101 Fax: +40 21 3158391 [[alternative HTML version deleted]]
file<- "\"Data labels\"" ?directory="\"/home/mylaptop/\"" ?cat("The file", file,"is located in directory",directory,sep=" ") The file "Data labels" is located in directory "/home/mylaptop/" A.K. ----- Original Message ----- From: Daniel Caro <dcarov at gmail.com> To: r-help at r-project.org Cc: Sent: Tuesday, April 9, 2013 6:06 AM Subject: [R] quotes in cat() within function 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. Thank you Daniel ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On Tue, Apr 9, 2013 at 3:06 AM, Daniel Caro <dcarov at gmail.com> 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=" ")cat("The file\"", file, "\"is located in directory\"", directory, "\", sep=" ") or use single quotes cat('The file"', file, '"is located in directory"', directory, '"', sep=" ") Hadley -- Chief Scientist, RStudio http://had.co.nz/
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