Create a new folder on your computer from R using the dir.create function.
  • path – A folder to be generated in the current working directory, or specify a path, e.g. "../../path/to/new/directory/newFolder".

Example. A folder 1202 is created to store February 2012 code from RFunction.com. The source code of the March 12 post is run to download the files and save them into that folder. Finally, I use list.files to see all the files that were downloaded. Note that the RCurl package must be installed to run the code from March 12.
> dir.create("1202")
> source("http://rfunction.com/code/1203/120312.R")
Loading required package: bitops
> list.files("1202")
 [1] "120201.R"              "120202.R"             
 [3] "120203.R"              "120204.R"             
 [5] "120205.R"              "120206.R"             
 [7] "120207.R"              "120208.R"             
 [9] "120209.R"              "120210.R"             
[11] "120211.R"              "120212.R"             
[13] "120213.R"              "120214.R"             
[15] "120215.R"              "120216.R"             
[17] "120217.R"              "120218.R"             
[19] "120219.R"              "120220.R"             
[21] "120221.R"              "120222.R"             
[23] "120223.R"              "120224.R"             
[25] "120225-tip.R"          "120225.R"             
[27] "120226.R"              "120227.R"             
[29] "120228.R"              "120229.R"             
[31] "BarackObamaTweets.txt" "data1.txt"            
[33] "par-120208.pdf" 

Leave a Reply