[R] download.file()

Henrik Bengtsson hb at stat.berkeley.edu
Tue Mar 18 16:59:45 CET 2008


On Tue, Mar 18, 2008 at 8:57 AM, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
> On Tue, Mar 18, 2008 at 8:46 AM, Paul Evans <p.evans48 at yahoo.com> wrote:
>  > Hi,
>  >
>  >  I wanted to download a file and did the following:
>  >  ---------------------------------------------------------
>  >  > fileLink <-  'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar'
>  >  > download.file(fileLink,'/geoDat')
>  >  trying URL 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar'
>  >  ftp data connection made, file length 35307520 bytes
>  >  opened URL
>  >  downloaded 34480Kb
>  >
>  >  >
>  >  ------------------------------------------------------------
>  >
>  >  However, when I look in the destination directory ('/geoDat'), the file is not there (I also tried giving it the absolute path).
>  >
>  >  What am I doing wrong?
>
>  I'm quite sure the 'destfile' argument of download.file() is a file
>  not a directory. Example:
>
>  > download.file("http://www.r-project.org/index.html", destfile="foo.html")
>  > file.info("foo.html")
>          size isdir mode               mtime               ctime
>  foo.html  785 FALSE  666 2008-03-18 08:54:19 2008-03-18 08:54:11
>                        atime exe
>  foo.html 2008-03-18 08:54:19  no
>
>  So you probably saved the downloaded file as 'geoDat' in the root
>  directory '/'.

Also, you want to download the file in a binary fashion, i.e. use
argument mode="wb", otherwise your binary tar file will be corrupt.

R-core: I'd suggest to replace the default to mode="wb" for file transfers.

/Henrik

>
>  /Henrik
>
>
>
>
>  >
>  >  thanks!
>  >
>  >
>  >
>  >
>  >       ____________________________________________________________________________________
>  >  Be a better friend, newshound, and
>  >
>  >
>  >         [[alternative HTML version deleted]]
>  >
>  >  ______________________________________________
>  >  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.
>  >
>



More information about the R-help mailing list