[R] merge words=data name

Charilaos Skiadas skiadas at hanover.edu
Mon Feb 12 03:22:29 CET 2007


On Feb 11, 2007, at 8:57 PM, Mark W Kimpel wrote:
> Duncan,
>
> Both yours and Gabor's methods were far superior to mine. I am curious
> why you like Gabor's better than yours.

Don't know if the following is why Duncan prefers Gabor's method, but  
here is why I would avoid the eval version: In general "eval" is very  
dangerous to call, unless you have full control over the expression  
you are asking it to evaluate. For instance imagine the following:

txt<- "system('ls')"
eval(parse(text=txt))

(replace 'ls' with 'dir' on a windows system)

With these two commands you will get a listing of everything in your  
home directory, or wherever the current path for R is. But suppose  
instead that the 'ls' was replaced by 'rm -rf *'. Then EVERYTHING in  
that directory will be DELETED, for ever, NO questions asked. (at  
least on a unix based system, perhaps even Windows with cygwin, I  
don't know. There is probably a similar call for windows).

In other words, make sure you know EXACTLY what the thing you are  
evaluating is.

I am not saying this is necessarily a danger here, but it brings up  
an important point that is good to be aware of.

Haris



More information about the R-help mailing list