Re: [问题] R读取JSONL(or JSON)格式的dataset

楼主: abc2090614 (casperxdd)   2016-10-28 22:40:55
※ 引述《pp61022 (fight)》之铭言:
library(dplyr)
library(jsonlite)
content <- readLines("roam_prescription_based_prediction.jsonl")
line1.cms <- fromJSON(readlines[1])$cms_prescription_count %>% as.data.frame
mydata <- line1.cms
for (i in 2:length(content)) {
mydata <- bind_rows(mydata, fromJSON(content[i])$cms_prescription_count
%>% as.data.frame)
}
这会parse出其中一个data frame
另一个类似方法操作吧...
作者: celestialgod (天)   2016-10-29 00:02:00
可以考虑直接lapply + bind_rows会比较有效率
作者: pp61022 (fight)   2016-10-29 11:49:00
谢谢! 这种方式也可以跑的出来!

Links booklink

Contact Us: admin [ a t ] ucptt.com