Recursively ftp download, then extract gz files
I have a multiple-step file download process I would like to do within R. I have got the middle step, but not the first and third...
# STEP 1 Recursively find all the files at an ftp site # <a href="ftp://prism.oregonstate.edu//pub/prism/pacisl/grids all_paths" title="ftp://prism.oregonstate.edu//pub/prism/pacisl/grids all_paths">ftp://prism.oregonstate.edu//pub/prism/pacisl/grids all_paths</a> <- #### a recursive listing of the ftp path contents??? #### # STEP 2 Choose all the ones whose filename starts with "hi" all_files <- sapply(sapply(strsplit(all_paths, "/"), rev), "[", 1) hawaii_log <- substr(all_files, 1, 2) == "hi" hi_paths <- all_paths[hawaii_log] hi_files <- all_files[hawaii_log] # STEP 3 Download & extract from gz format into a single directory mapply(download.file, url = hi_paths, destfile = hi_files) ## and now how to extract from gz format?
