Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try using the command "download.file".</p> <pre><code>### set up the path and destination path &lt;- "url where file is located" dest &lt;- "where on your hard disk you want the file saved" ### Ask R to try really hard to download your ".csv" try(download.file(path, dest)) </code></pre> <p>The trick to this is going to be figuring out how the "url" or "path" changes systematically between files. Often times, web pages are built such that the "url's" are systematic. In this case, you could potentially create a vector or data frame of url's to iterate over inside of an apply function.</p> <p>All of this can be sandwiched inside of an "lapply". The "data" object is simply whatever we are iterating over. It could be a vector of URL's or a data frame of year and month observations, which could then be used to create URL's within the "lapply" function.</p> <pre><code>### "dl" will apply a function to every element in our vector "data" # It will also help keep track of files which have no download data dl &lt;- lapply(data, function(x) { path &lt;- 'url' dest &lt;- './data_intermediate/...' try(download.file(path, dest)) }) ### Assign element names to your list "dl" names(dl) &lt;- unique(data$name) index &lt;- sapply(dl, is.null) ### Figure out which downloads returned nothing no.download &lt;- names(dl)[index] </code></pre> <p>You can then use "list.files()" to merge all data together, assuming they belong in one data.frame</p> <pre><code>### Create a list of files you want to merge together files &lt;- list.files() ### Create a list of data.frames by reading each file into memory data &lt;- lapply(files, read.csv) ### Stack data together data &lt;- do.call(rbind, data) </code></pre> <p>Sometimes, you will notice the file has been corrupted after downloading. In this case, pay attention to the option contained within the download.file() command, "mode". You can set mode = "w" or mode = "wb" if the file is stored in a binary format.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload