[R] scripts with littler
    Jeffrey Horner 
    jeff.horner at vanderbilt.edu
       
    Tue Jan  9 20:52:41 CET 2007
    
    
  
John Lawrence Aspden wrote:
> John Lawrence Aspden wrote:
> 
>> I'm actually tempted to use
>>
>> #!/usr/bin/env r
>> rm(list=ls())
> 
> Ahem, it turns out to be better to use:
> 
> #!/usr/bin/env r
> rm(list=ls()[ls()!="argv"])
> 
Eww!! I'm not sure you want to do that. I would recommend sticking with:
#!/usr/bin/r -v
as that gives you a "truer" scripting environment. I understand that 
won't load the libraries in your home area automatically, but consider 
the way scripts in other languages are written and distributed: they 
usually load the libraries at the beginning of the script. Silently 
loading them before the script is run hides behavior from the script user.
If you have libraries installed outside of the library search path, 
consider expanding it with .libPaths() before calling library() or 
require().
Cheers,
Jeff
-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner
    
    
More information about the R-help
mailing list