[R] Reading multiple line from a JSON formatted file

Shelby McIntyre smcintyre at scu.edu
Sun Jul 8 15:50:36 CEST 2012


Below is R code that successfully reads the first line of a JSON file (attached). 
However, it is supposed to read 5 lines of the file, not just one.  What is the 
wrong? 

==================== 
>library("rjson") 
>json_file <- "/Users/smcintyremobile/Google Drive/AAShelby/CORRESP/Services Research/eWoM references for Ed/yelp_academic_dataset SAMPLE.txt" 
>json_data <- fromJSON(paste(readLines(json_file,n=5), collapse="")) 
>json_data 
$votes 
$votes$funny 
[1] 1 

$votes$useful 
[1] 8 

$votes$cool 
[1] 1 


$user_id 
[1] "TFm6azL9LLpljgVKx-Vfkw" 

$name 
[1] "E L." 

$url 
[1] "http://www.yelp.com/user_details?userid=TFm6azL9LLpljgVKx-Vfkw" 

$average_stars 
[1] 3.5 

$review_count 
[1] 12 

$type 
[1] "user" 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Yelp-academic-dataset SAMPLE.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120708/407631fe/attachment.txt>


More information about the R-help mailing list