0

I've been working on this code for a while now, basically I need to read the files from this directory, but I keep getting an error "cannot open the connection", please help me to see which part went wrong?

Hope this code doesn't confuse you much, really wanted to figure out how to get all the files end with .M files(.M09 or .M10) from the above link, if you have better ideas of achieving that, please help, thank you.

file.path.in <- file.path("C:", "Users", "agclim", "GAData", fsep=.Platform$file.sep); # Windows                             
file.extension <- c("(\\.M\\d{2})"); 
filename.in.all <- list.files(file.path.in, pattern=paste(file.extension,"+$",sep=""), full.names=FALSE);    
filename.in.all <- sort(filename.in.all, decreasing=FALSE);        
library("gdata");
for (i.in in 1:length(filename.in.all)) { 
    cat(paste("The data in the",filename.in.all[i.in],"file are processing now.", sep=" "), "\n");
    url.conn.server <- url(file.path("ftp://agrofawn-prod01.osg.ufl.edu","pub", "howard","georgia",filename.in.all[i.in],fsep=.Platform$file.sep), open="r", blocking=TRUE, encoding=getOption("encoding"));    
    data.01 <- readLines(url.conn.server, n=-1, ok=TRUE);                     
    unlink(url.conn.server);
    close(url.conn.server);
}
4

1 に答える 1

0

あなたはあなたの電話のfile.path()ビットを望んでいません。url()代わりにこれを試してください:

ftp_url <- "ftp://agrofawn-prod01.osg.ufl.edu/pub/howard/georgia/"
# ...skipping loop logic...
url.conn.server <- url(paste(ftp_url, filename.in.all[i.in], sep=""))
于 2013-02-06T18:59:21.700 に答える