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

Duncan Murdoch murdoch.duncan at gmail.com
Sun May 1 13:42:23 CEST 2011


Please upgrade to a current release (or R-patched).  Version 2.10.1 is 
quite old.

Duncan Murdoch

On 30/04/11 3:18 PM, Oliver wrote:
> Hello,
>
> 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
>
>    options(width=Sys.getenv("COLUMNS"))
>
> 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
> status
> 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?!)
>
> Ciao,
>     Oliver
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list