Use R to view and manipulate the File System

February 21, 2011
By

(This article was first published on Data Twirling, and kindly contributed to R-bloggers)

One of the best ways to learn how to code in R is to view sample scripts that people share.

I recently came across this post where Michael uses R to scrape twitter and collect all sorts of great data on the current unrest in the Middle East and northern Africa.  While the post is worthy of a read itself, what I found useful was the function ?file.exists.  The usage is obvious, but the help file exposed a collection of functions that I was not previously aware of.

For instance, I have used ?unlink before, but I had no idea that you could use R to create directories, walk file paths, etc.  I can’t speak for SAS, but I am quite certain you can’t do this natively in SPSS.

I have to admit that I probably should have already known about this, but the ability to programmatically manipulate files and directories are the sorts of things that keep affirming that time learning R is well spent.



To leave a comment for the author, please follow the link and comment on his blog: Data Twirling.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.