[R] contriburl argument to install.packages

John Fox jfox at mcmaster.ca
Fri Jul 16 04:29:18 CEST 2004


Dear Roger,

After Duncan pointed out my error, I was able to get things to work fine.
(The context was a discussion on the R-GUI list, in response to which I
wrote a tcltk dialog to download missing packages or install them from a
local directory. It was the latter that was giving me trouble -- because I
misinterpreted PACKAGES as a directory.)

Anyway, thanks for your help.
 John 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Roger D. Peng
> Sent: Thursday, July 15, 2004 7:17 PM
> To: John Fox
> Cc: r-help at stat.math.ethz.ch; 'Duncan Murdoch'
> Subject: Re: [R] contriburl argument to install.packages
> 
> Hmm...is this maybe a bug?  Check out this section of
> install.packages():
> 
>      localcran <- length(grep("^file:", contriburl)) > 0
>      if (!localcran) {
>          if (is.null(destdir)) {
>              tmpd <- tempfile("Rinstdir")
>              if (!dir.create(tmpd))
>                  stop("Unable to create temp directory ", tmpd)
>          }
>          else tmpd <- destdir
>      }
>      foundpkgs <- download.packages(pkgs, destdir = tmpd, 
> available = available,
>          contriburl = contriburl, method = method)
> 
> So if `localcran' is TRUE (which in this case, it is), then 
> `tmpd' never gets defined but is passed to download.packages().
> 
> When I run a traceback() after getting the error from running 
> install.packages(), it fails in download.packages() when 
> trying to create the download directory.
> 
> For example, try defining `tmpd' in your workspace and the 
> run install.packages.  This works for me:
> 
> tmpd <- "~/tmp"
> install.packages("bzTools", contriburl = "file:c:/Rlibs/build")
> 
> Of course, you still need the PACKAGES file in the contriburl 
> directory.
> 
> -roger
> 
> John Fox wrote:
> > Dear Duncan,
> > 
> > 
> >>-----Original Message-----
> >>From: r-help-bounces at stat.math.ethz.ch 
> >>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> Duncan Murdoch
> >>Sent: Thursday, July 15, 2004 9:56 AM
> >>To: John Fox
> >>Cc: r-help at stat.math.ethz.ch
> >>Subject: Re: [R] contriburl argument to install.packages
> >>
> >>On Thu, 15 Jul 2004 10:09:46 -0400, "John Fox" 
> >><jfox at mcmaster.ca> wrote :
> >>
> >>
> >>>Dear list members,
> >>>
> >>>I can't figure out how to specify the contriburl argument to
> >>>install.packages() properly when the packages to be
> >>
> >>installed are in a
> >>
> >>>directory on my local machine. I have in mind a command
> >>
> >>something like
> >>
> >>>	install.packages(missing.packages, contriburl=directory,
> >>>lib=.libPaths()[1])
> >>>
> >>>Where missing.packages is a character vector of package
> >>
> >>names (without
> >>
> >>>versions) and directory is the location where they reside (less 
> >>>PACKAGES, I guess). I'm using R version 1.9.1 on a Windows
> >>
> >>XP machine. 
> >>
> >>>Several variations on directory <- "file:c:/temp" don't 
> seem to work.
> >>>
> >>>Any help would be appreciated.
> >>
> >>You need a file called PACKAGES in the same directory as 
> the packages, 
> >>which contains the package information; for example
> >>
> >> http://www.cran.mirrors.pair.com/bin/windows/contrib/1.9/PACKAGES
> >>
> >>I imagine the CRAN maintainers have scripts to produce this 
> from the 
> >>package files, but I'm not sure where they are.
> >>
> >>To refer to a local version of this file, use the syntax 
> you had, e.g.
> >>
> >> CRAN.packages(contriburl="file:c:/temp")
> >>
> >>will look for c:/temp/PACKAGES and display the information in it.  
> >>
> > 
> > 
> > I had already tried this, and it doesn't appear to work for me. For 
> > example,
> > 
> > 	> CRAN.packages(contriburl="file:c:/temp")
> > 	Error in file(file, "r") : unable to open connection
> > 	In addition: Warning message: 
> > 	cannot open file `c:/temp/PACKAGES' 
> > 
> > I *do* have a directory c:\temp\PACKAGES
> > 
> > Regards,
> >  John
> > 
> > 
> > 
> > 
> >>If you don't want to maintain this file, then you can construct the 
> >>information in it using the "available="
> >>argument to the package functions.
> >>
> >>Duncan
> > 
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! 
> > http://www.R-project.org/posting-guide.html
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list