First, try the example in the test file (tests/internet.R)

read.table("ftp://ftp.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat";)

or

download.file("ftp://ftp.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat";, "test"

That is known to work on many, many R systems.

I get the same error as you on that URL, but it looks to me that the site required PASV ftp, something R's download.file does not support.
From the detailed logs (options(internet.info=0)

<<<
230---------------------------------------------------------
230-                    Welcome To The
230-     Natural Resources Conservation Service - USDA
230-             NATIONAL WATER and CLIMATE CENTER
230---------------------------------------------------------
230-
230-    The Local Date and Time is Mon Jan 12 08:30:25 2009
230-    Current Directory is /
230-    Information Contact is: i...@wcc.nrcs.usda.gov
230-    -----------------------------------------------------------
230-    Note that data files herein are at most updated once an hour.
230-
230 Guest login ok, access restrictions apply.

--
19: In download.file(url, dest) :
---

--
20: In download.file(url, dest) : Got 230
21: In download.file(url, dest) : Invalid answer to PASV

Since you are on Windows, using --internet2 (see the rw-FAQ) might work.

On Mon, 12 Jan 2009, zack holden wrote:


Dear list,

I am trying to download a text file from an ftp site using download.file().

I used the following code:
url <- 
"ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt";
dest <- "c:/test/downloadtest.txt"
download.file(url, dest)
I get this error message, indicating that R is unable to open the connection:
trying URL 
'ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt'
Error in download.file(url, dest) :
 cannot open URL 
'ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt'

I'm sure there is a simple solution that allows R to open this connection, but after 
reading the "url" help file for an hour, I can't seem to find the solution. Is 
anyone willing to help me solve this problem?

thanks in advance for any advice,

Zack

--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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.

Reply via email to