[R] Can't get installing a package source (.tar.gz) from a web page to work...

Martin Morgan mtmorgan at fhcrc.org
Fri Sep 16 18:27:15 CEST 2011


On 09/16/2011 04:21 AM, Søren Højsgaard wrote:
> Thanks Uwe,
>
> The problem, however, is not solved. If I do:
>
> download.file("http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz",
> tempdir()) Error in
> download.file("http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz",
> : cannot open destfile 'c:\temp\RtmpcrQ0WM', reason 'Permission
> denied'
>
>
> However, if I specify a filename then things are working:
> download.file("http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz",
> paste(tempdir(),"thisfile",sep="\\")) trying URL
> 'http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz'
>
>
Content type 'application/x-tar' length 315847 bytes (308 Kb)
> opened URL downloaded 308 Kb
>
> dir(tempdir()) [1] "thisfile"
>
> According to to the documentation:
>
> "Destfile A character string with the name where the downloaded file
> is saved. Tilde-expansion is performed."

A little ambiguous, but I guess it is the full path of the downloaded 
file; 'destfile' and not 'destdir'.

Perhaps you mean tempfile() (a file name that can be created in R's 
temporary directory) rather than tempdir() (R's temporary directory). 
Otherwise you are trying to open for writing a location that is an 
in-use directory, and Windows is saying that you can't do that.

Martin

> I read the documentation such that I can specify a directory in which
> the file is to be put, but I may be wrong; or is it possible that
> there is a bug somewhere?
>
> Best regards Søren
>
>
>
>
>
>
>
>
>
>
>
> -----Oprindelig meddelelse----- Fra: Uwe Ligges
> [mailto:ligges at statistik.tu-dortmund.de] Sendt: 15. september 2011
> 10:47 Til: Søren Højsgaard Cc: r-help at stat.math.ethz.ch Emne: Re: [R]
> Can't get installing a package source (.tar.gz) from a web page to
> work...
>
>
>
> On 15.09.2011 10:34, Søren Højsgaard wrote:
>> I have created an R-package with datasets which I want my students
>> to install (the package is not on CRAN).
>>
>> 1) I've put the package on the web in a directory called 'data' and
>> I thought I could do:
>>
>>> install.packages("http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz",repos=NULL,type="source")
>>
>>
>>>
Warning: invalid package 
'http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz'
>> Error: ERROR: no packages specified Warning messages: 1: running
>> command 'C:/programs/R/current/bin/i386/R CMD INSTALL -l
>> "C:/programs/R/current/library"
>> "http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz"'
>> had status 1 2: In
>> install.packages("http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz",
>> : installation of package
>> 'http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz'
>> had non-zero exit status
>
>
> Right, install.packages assumes a package name or a file path. URLs
> (or any othr connections) are not supported.
>
>
>> 2) I've then put the package in data/src/contrib/ and try:
>>
>>> install.packages('LiSciData_0.0-03.tar.gz',repos='http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/',
>>> type='source')
>> Warning: unable to access index for repository
>> http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/src/contrib
>>
>>
Warning message:
>> In getDependencies(pkgs, dependencies, available, lib) : package
>> 'LiSciData_0.0-03.tar.gz' is not available (for R version 2.13.1)
>
> If you want to use it as a repository, you have to make such a
> repository. For a source repository, create subdirs ./src/contrib
> and put your package there. Afterwards, you can run
> tools::write_PACKAGES on that directory in order to create PACKAGES
> and PACKAGES.gz files for that repository.
>
>
>> 3) If I put the package in the Rs working directory then the
>> following works:
>>> install.packages("LiSciData_0.0-03.tar.gz",repos=NULL,type="source")
>
>>>
> Right, hence you can also tell your students to:
>
> download.file("http://gbi.agrsci.dk/statistics/courses/2011-ISMLS-course/data/LiSciData_0.0-03.tar.gz",
>
>  tempdir()) install.packages(file.path(tempdir(),
> 'LiSciData_0.0-03.tar.gz'), repos=NULL, type='source')
>
> Best wishes, Uee
>
>
>
>
>
>> I would much prefer if it could be done directly from the web in
>> the spirit of attempt 1) above (because then fewer things can go
>> wrong for the students). Any hint on what I am doing wrong?
>> sessionInfo() shown below.
>>
>> Regards Søren
>>
>>
>>
>>> sessionInfo()
>> R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386
>> (32-bit) locale: [1] LC_COLLATE=Danish_Denmark.1252
>> LC_CTYPE=Danish_Denmark.1252    LC_MONETARY=Danish_Denmark.1252
>> LC_NUMERIC=C                    LC_TIME=Danish_Denmark.1252
>> attached base packages: [1] stats     graphics  grDevices utils
>> datasets  methods   base other attached packages: [1] SHDtools_1.0
>> loaded via a namespace (and not attached): [1] tools_2.13.1
>> ______________________________________________ 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.
>
> ______________________________________________ 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.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the R-help mailing list