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
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.
Apparently Analagous Threads
- export variable from bash to R
- passing command line arguments to 'R CMD BATCH myScript.R'
- Sys.getenv
- .Platform addition (was Re: where does R search when source()?)
- Sys.getenv(): Error in substring(x, m + 1L) : invalid multibyte string at '<ff>' if an environment variable contains \xFF