7

I need to:

  1. Download a parsed file of all the company names provided by http://api.crunchbase.com/v/1/companies.js

  2. Run a query using each company name to download a parsed file of each company's information (e.g. Founded_year, funder company name), using the syntax 'http://api.crunchbase.com/v/1/company/permalink.js'

I would like to parse this data into a spreadsheet or some other format that I can then import into R for analysis.

What is the best format to import this data into R? How can I download the data and organize it into a table-like structure? (e.g. Row = company, columns = profile information like funded_year) (with the ultimate goal of analyzing it in R)

Peter O.
  • 32,158
  • 14
  • 82
  • 96
user1764260
  • 91
  • 1
  • 1
  • 3
  • possible duplicate of [Importing data from a JSON file into R](http://stackoverflow.com/questions/2617600/importing-data-from-a-json-file-into-r) – mnel Oct 22 '12 at 04:06

1 Answers1

11
library(RJSONIO)
library(RCurl)

# grab the data
raw_data <- getURL("http://api.crunchbase.com/v/1/companies.js")
# Then covert from JSON into a list in R
data <- fromJSON(raw_data)
length(data)
[1] 101782
# We can coerce this to a data.frame
 final_data <- do.call(rbind, data)
 # Then write it to a flat csv file
 write.csv(final_data, "final_data.csv")


> head(final_data)
     name                permalink     category_code
[1,] "Wetpaint"          "wetpaint"    "web"        
[2,] "AdventNet"         "adventnet"   "enterprise" 
[3,] "Zoho"              "zoho"        "software"   
[4,] "Digg"              "digg"        "web"        
[5,] "Facebook"          "facebook"    "web"        
[6,] "Photobucket, Inc." "photobucket" "web"        
Maiasaura
  • 32,226
  • 27
  • 104
  • 108
  • 1
    Thanks! This solved my problem of getting the company names into a CSV file in R. Now I need to get the details of each company organized into a database in R. Is the best way to do this by looping through each permalink within the api call ('http://api.crunchbase.com/v/1/company/permalink.js') and adding each company's profile data to a single csv within R? How would I do that? – user1764260 Oct 22 '12 at 04:27