It's true that I could avoid the modularity, but it improves readability
and maintainability immensely.
Here are my results to three suggestions. The pathnames below are all
abbreviated for readability.
1. do.call seems to work.
Both of the following successfully read the data in:
read.dta("C:/Documents and Settings/mexchn_gary.dta", convert.factors=FALSE)
do.call("read.dta", list(file="C:/Documents and Settings/mexchn_gary.dta", convert.factors=FALSE))
2. quotes within quotes:
Correspondants suggested using single quotes or backslashes to escape
the quotes. It turns out R interprets both the same way.
cmd <- "read.dta"
opt <- "convert.factors=FALSE"
data.file <- 'file="C:/Documents and Settings/mexchn_gary.dta"'
do.call(cmd, list(data.file, opt))
Error in read.dta("file=\"C:/Documents and Settings/mexchn_gary.dta\"", :
unable to open file