Yes, Rui, it did work. Thank you very much for your help. Or maybe I should say "muito obrigada!"
Rita ===================================== "If you think education is expensive, try ignorance."--Derek Bok ________________________________ > Date: Fri, 20 Apr 2012 11:15:06 -0700 > From: ml-node+s789695n457488...@n4.nabble.com > To: ritacarre...@hotmail.com > Subject: Re: pasting a formula string with double quotes in it > > Hello, > > StellathePug wrote > Hello everyone, > I have tried several ways of doing this and searched the documentation > and help lists and I have been unable to find an answer or even whether > it is possible to do it. I am pasting together a formula and I need to > insert double quotes around the strings. Here's an example: > > location <- c("AL", "AK", "MA", "PA") > v=2 > test <- cbind( > " <- cbind(df$DATE[df$LOCATION %in% c(", > location[v], > ")], df$WTD.AVG.PRICE[df$LOCATION %in% c(", > location[v], > ")])") > > test <- paste(test, collapse="") > test > > Solution: > [1] " <- cbind(df$DATE[df$LOCATION %in% c(AK)], > df$WTD.AVG.PRICE[df$LOCATION %in% c(AK)])" > > This does not produce an error message but it is obviously wrong > because I need double quotes around AK, i.e., > " <- cbind(df$DATE[df$LOCATION %in% c("AK")], > df$WTD.AVG.PRICE[df$LOCATION %in% c("AK")])" > And obviously, I gave R no indication whatsoever to use double quotes. > > > If I use > test <- paste(test, collapse=""") > it does not work, which makes sense because the second double quote > closes the first and the third is left an orphan. > > Anyone have any ideas? > [[elided Hotmail spam]] > Rita > Use single quotes instead, they don't close the double quotes and, for > this, the result is the same. > Look at the end/beginning of the lines before/after location[v] > > test2 <- cbind( > " <- cbind(df$DATE[df$LOCATION %in% c('", > location[v], > "')], df$WTD.AVG.PRICE[df$LOCATION %in% c('", > location[v], > "')])") > test2 <- paste(test2, collapse="") > test2 > > Hope this helps, > > Rui Barradas > > > ________________________________ > If you reply to this email, your message will be added to the > discussion below: > http://r.789695.n4.nabble.com/pasting-a-formula-string-with-double-quotes-in-it-tp4574419p4574888.html > > To unsubscribe from pasting a formula string with double quotes in it, > click > here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4574419&code=cml0YWNhcnJlaXJhQGhvdG1haWwuY29tfDQ1NzQ0MTl8LTE1MTg5NTk0NzI=>. > > NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble:email.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble:email.naml-instant_emails%21nabble:email.naml-send_instant_email%21nabble:email.naml> > -- View this message in context: http://r.789695.n4.nabble.com/pasting-a-formula-string-with-double-quotes-in-it-tp4574419p4575202.html Sent from the R help mailing list archive at Nabble.com. [[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.