Blog Archives

R: A Quick Scrape of Top Grossing Films from boxofficemojo.com

January 13, 2012
By
R: A Quick Scrape of Top Grossing Films from boxofficemojo.com

  Introduction I was looking at a list of the top grossing films of all time (available from boxofficemojo.com) and was wondering what kind of graphs I would come up with if I had that kind of data. I still don’t know what kind of graphs I’d construct other than a simple barplot but figured

Read more »

R: Web Scraping R-bloggers Facebook Page

January 6, 2012
By
R: Web Scraping R-bloggers Facebook Page

  Introduction R-bloggers.com is a blog aggregator maintained by Tal Galili. It is a great website for both learning about R and keeping up-to-date with the latest developments (because someone will probably, and very kindly, post about the status of some R related feature). There is also an R-bloggers facebook page where a number of

Read more »

Plotting Doctor Who Ratings (1963-2011) with R

January 3, 2012
By
Plotting Doctor Who Ratings (1963-2011) with R

Introduction First day back to work after New Year celebrations and my brain doesn’t really want to think too much. So I went out for lunch and had a nice walk in the park. Still had 15 minutes to kill before my lunch break was over and so decided to kill some time with a quick web

Read more »

Unshorten (almost) any URL with R

December 13, 2011
By
Unshorten (almost) any URL with R

Introduction I was asked by a friend how to find the full final address of an URL which had been shortened via a shortening service (e.g., Twitter’s t.co, Google’s goo.gl, Facebook’s fb.me, dft.ba, bit.ly, TinyURL, tr.im, Ow.ly, etc.). I replied I had no idea and maybe he should have a look over on StackOverflow.com or, possibly,

Read more »

Code Optimization: One R Problem, Thirteen Solutions – Now Sixteen!

December 8, 2011
By
Code Optimization: One R Problem, Thirteen Solutions – Now Sixteen!

Introduction The old r-wiki optimisation challenge describes a string generation problem which I have bloged about previously both here and here. The Objective To code the most efficient algorithm, using R, to produce a sequence of strings based on a single integer input, e.g.: Solutions One Through Thirteen A variety of different approaches are illustrated on the

Read more »

Installing Rcpp on Windows 7 for R and C++ integration

December 7, 2011
By
Installing Rcpp on Windows 7 for R and C++ integration

Introduction Romain Francois presented an Rcpp solution on his blog to an old r-wiki optimisation challenge which I had also presented R solutions for previously on my blog. The Rcpp package provides a method for integrating R and C++. This allows for faster execution of an R project by recoding the slower R parts into C+ and thus providing potential performance enhancements.

Read more »

outersect(): The opposite of R’s intersect() function

November 29, 2011
By
outersect(): The opposite of R’s intersect() function

The Objective To find the non-duplicated elements between two or more vectors (i.e. the ‘yellow sections of the diagram above) The Problem I needed the opposite of R’s intersect() function, an “outersect()“. The closest I found was setdiff() but the order of the input vectors produces different results, e.g. setdiff() produces all elements of the first

Read more »

source_https(): Sourcing an R Script from github over HTTPS

November 24, 2011
By
source_https(): Sourcing an R Script from github over HTTPS

The Objective I wanted to source R scripts hosted on my github repository for use in my blog (i.e. a github version of ?source). This would make it easier for anyone wishing to test out my code snippets on their own computers without having to manually go to my github repo and retrieve a series of R

Read more »

htmlToText(): Extracting Text from HTML via XPath

November 18, 2011
By
htmlToText(): Extracting Text from HTML via XPath

Converting HTML to plain text usually involves stripping out the HTML tags whilst preserving the most basic of formatting. I wrote a function to do this which works as follows (code can be found on github): The above uses an XPath approach to achieve it’s goal. Another approach would be to use a regular expression. These

Read more »

fgui: Automatically Creating Widgets for Arguments of a Function – A Quick Example

November 16, 2011
By
fgui: Automatically Creating Widgets for Arguments of a Function – A Quick Example

Here’s something I came across by accident, an R package called fgui which has the ability to automatically create a widget just by passing it a function with parameters, e.g.: The GUI produced from the code above looks like this: I love how easy that was to do, very cool, and useful too! The package

Read more »