Use R to view and manipulate the File System

February 21, 2011

(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 their blog: Data Twirling. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)