From pgilbert902 at gmail.com  Tue Sep 24 03:03:33 2013
From: pgilbert902 at gmail.com (Paul Gilbert)
Date: Mon, 23 Sep 2013 21:03:33 -0400
Subject: [Rd] Capture output of install.packages (pipe system2)
In-Reply-To: <CABdHhvFmgvADrBJui5=+MjgOOGrjERcipxpiNd2tNP+P_vicDQ@mail.gmail.com>
References: <CABFfbXtWhc48KviWCQXR84xGywm1GU0oMWk1Vk7s0EqbcAfT5g@mail.gmail.com>
	<5240A280.1000804@gmail.com>
	<F165061B-F2DF-47CF-898F-920DC27C0DF7@r-project.org>
	<5240C5B8.4030301@gmail.com>
	<CABdHhvFmgvADrBJui5=+MjgOOGrjERcipxpiNd2tNP+P_vicDQ@mail.gmail.com>
Message-ID: <5240E4E5.7030905@gmail.com>


On 13-09-23 08:20 PM, Hadley Wickham wrote:
>> Brian Ripley's reply describes how it is done in the tools package.  For
>> example, as I sent privately to Jeroen,
>>
>> x <- system2("Rscript", "-e \"install.packages('MASS',
>> repos='http://probability.ca/cran')\"", stdout=TRUE, stderr=TRUE)
>>
>> captures all of the output from installing MASS.  As Jeroen pointed out,
>> that isn't identical to running install.packages() in the current session; a
>> real version of it should fill in more of the arguments, not leave them at
>> their defaults.
>
> It does seems a little crazy that you're in a R process, then open
> another one, which then opens a 3rd session! (often indirectly by
> calling R CMD install which then calls an internal function in tools)

It does seem very much more straight forward to do this in the process 
above R:

   R --vanilla --slave -e "install.packages('whatever',
    repo='http://cran.r-project.org')" >R.out  2>&1

(Omit mailer wrap.) Your mileage may vary depending on your OS.

Paul

>
> Hadley
>



[Rd] Capture output of install.packages (pipe system2)
Paul Gilbert