Re: [Rd] Best way to locate R executable from within R?

From: Dan Tenenbaum <dtenenba_at_fhcrc.org>
Date: Tue, 22 May 2012 10:47:47 -0700

On Tue, May 22, 2012 at 10:34 AM, Henrik Bengtsson <hb_at_biostat.ucsf.edu> wrote:
> Hi,
>
> I'd like to spawn of a new R process from within R using system(),
> e.g. system("R -f myScript.R").  However, just specifying "R" as in
> that example is not guaranteed to work, because "R" may not be on the
> OS's search path.
>
>  What is the best way, from within a running R, to infer the command
> (basename or full path) for launching R in way that it works on any
> OS?  I came up with the following alternatives, but I'm not sure if
> they'll work everywhere or not:
>
> 1. Rbin <- commandArgs()[1];
>
> 2. Rbin <- file.path(R.home(), "bin", "R");
>
> Other suggestions that are better?

Rbin <- file.path(Sys.getenv("R_HOME"), "bin", "R")

Dan

>
> /Henrik
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 22 May 2012 - 17:50:09 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 May 2012 - 18:41:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive