How does one put quotes within quotes, if it's possible? I've tried replacing one set of the quotes by single quotes. If it's not possible, is there any way to do the following? > cmd <- "read.dta" > opt <- "convert.factors=FALSE" > data.file <- " file="/full/path/name.dta" " > eval(call(cmd,data.file,opt)) Prior to adding this option, I had been using match.fun to get the function call corresponding to cmd and then evaluating it, but match.fun doesn't seem to help here. Thanks, Janet
Two ways: (a) Use single and double qoutes, e.g., "'" is the character string consisting of a single apostrophe, while '"' is the character string consisting of a single (double) quote mark. (b) "\"" == '"'; '\'' == "'" Also, you example suggests you may wish to try "paste". Spencer Graves janet rosenbaum wrote:> How does one put quotes within quotes, if it's possible? > I've tried replacing one set of the quotes by single quotes. > > If it's not possible, is there any way to do the following? > > > cmd <- "read.dta" > > opt <- "convert.factors=FALSE" > > data.file <- " file="/full/path/name.dta" " > > eval(call(cmd,data.file,opt)) > > Prior to adding this option, I had been using match.fun to get the > function call corresponding to cmd and then evaluating it, but match.fun > doesn't seem to help here. > > Thanks, > > Janet > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
You may want to investigate using do.call(). For example, do.call("read.dta",list(convert.factors=FALSE, file="/full/path/name.dta")) Or else, maybe a conbination of paste() and parse()/eval(). -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Tue, 8 Apr 2003, janet rosenbaum wrote:> > How does one put quotes within quotes, if it's possible? > I've tried replacing one set of the quotes by single quotes. > > If it's not possible, is there any way to do the following? > > > cmd <- "read.dta" > > opt <- "convert.factors=FALSE" > > data.file <- " file="/full/path/name.dta" " > > eval(call(cmd,data.file,opt)) > > Prior to adding this option, I had been using match.fun to get the > function call corresponding to cmd and then evaluating it, but match.fun > doesn't seem to help here. > > Thanks, > > Janet > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >