[R] Sys.getenv at startup is not working properly

Oliver oliver at first.in-berlin.de
Sat Apr 30 21:18:53 CEST 2011


when using

Sys.getenv() during startup-phase (.First or .Rprofile)
 to get the env-variables
COLUMNS as well as HOST I get empty strings.

After the startup is done, when asking via Sys.getenv()
by hand, COLUMNS is set (but HOST is not, even "hostname" on the shell gives me
a correct answer).

At the moment my problem is the missing COLUMNS value during start up,
because I want to set the linewidth for printing via


automatically at startup.

When using
$ R CMD BATCH myscript.R
the same problem occurs, but then at least I can understand
the case (but interpreting "" as "0" by the options() would be better,
because the option-setting would then not break the script; it does break the
script, when COLUMNS is "").

(btw: Is there a possibility to decide if the script is running in batch mode or
interactively? This could be a workaround for "" not interpreted as "0".)

The setting with the options/Sys.getenv() works, when typed in by hand
after startup is completed, as well as when sourcing-in a script that
contains such a options/Sys.getenv-command.

here is, what R.version contains:
platform       x86_64-pc-linux-gnu          
arch           x86_64                       
os             linux-gnu                    
system         x86_64, linux-gnu            
major          2                            
minor          10.1                         
year           2009                         
month          12                           
day            14                           
svn rev        50720                        
language       R                            
version.string R version 2.10.1 (2009-12-14)

Is this problem fixed in newer releases?
Or if not: how can I inform the R developers, so that they can
pick it up?
(Some R developers might be on this list?!)


More information about the R-help mailing list