[R] Parse Expression
murdoch at stats.uwo.ca
Mon Dec 17 12:50:58 CET 2007
> Hello everyone, I would like to construct a datafram with the following
> eval(parse(text=paste("df=data.frame(", cmd, ")", sep="")))
> But it comes out " Error in parse(file, n, text, prompt, srcfile, encoding)
> syntax error, unexpected $undefined, expecting ',' in
> "df=data.frame(cbcDummy10to12 = 1,cbcForeWrld_Ret = 1,cbcYC10-2_"
> "cmd" is a character string I obtained before, it is like:
>  "cbcDummy10to12 = 1,cbcForeWrld_Ret = 1,cbcYC10-2_wld = 1"
> Could anyone give me some advice? Many thanks.
You can't have a hyphen "-" in a variable name, i.e. cbcYC10-2_wld is
not legal. It is treated as a subtraction.
I think the "$undefined" refers to 2_wld; the parser has no idea what
that is supposed to be.
More information about the R-help