Understanding Wikipedia Data Using R
Share this post
Note: In order to see the details of the commands and screen-based information it is best to view this video full screen and in HD. However, if you’d like to have a go yourself, we strongly recommend you follow the instructions in the text below. Here, we tell you what the commands in the video are, and we also have made a couple of small updates to the text since we recorded this video which will help you get your code to work. You’ll find following the text a lot easier than copying the commands from the video.
Wikipedia’s Available Data
Understanding Wikipedia Data Using R
R and R Studio
cat("Hello, World...")
cat("Hello again, World!") # This is a comment
Command R
?install.packages
Understanding Wikipedia Data Using R
install.packages("RCurl")
library(RCurl)
getURL("http://stats.grok.se/json/en/201410/Friday")
rawData <- getURL("http://stats.grok.se/json/en/201410/Friday")
rawData
install.packages("RJSONIO") # Install the JSON parser
library(RJSONIO) # Load the JSON parser
Note: where the code consists of more than one line of code you must hit ‘Enter’ at the end of each line.
To parse the JSON, we can use a function called “fromJSON”:
fromJSON(rawData)
What comes out of this function looks a bit more understandable, particularly the bit under “$daily_views”. Let’s save the parsed data in a variable called “parsedData”:
parsedData <- fromJSON(rawData)
Let’s check what’s now saved in parsedData, by typing the variable name into the Console:
parsedData
… looks good.
How can we access the information in the variable labelled “$daily_views”? Try typing this in
parsedData$daily_views
OK – it looks like we’ve got something which is a bit more like a table!
Excellent – you’ve downloaded data on how often people are looking at a Wikipedia page and loaded it into R!
Share this post
Big Data: Measuring And Predicting Human Behaviour

Big Data: Measuring And Predicting Human Behaviour

Our purpose is to transform access to education.
We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.
We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.
Learn more about how FutureLearn is transforming access to education
Register to receive updates
-
Create an account to receive our newsletter, course recommendations and promotions.
Register for free