楼主: peishenfei
10448 13

[问答] 合并list [推广有奖]

11
peishenfei 发表于 2017-3-11 12:44:12
swyggq 发表于 2017-3-9 23:35
不过话说……我并不确定逐行rbind会不会死
a=data.frame(a)
b=data.frame(b)
不好意思,之前没有看到你的回复,是这样的,json文件原来的样子是


{"reviewerID": "A2IBPI20UZIR0U", "asin": "1384719342", "reviewerName": "cassandra tu \"Yeah, well, that's just like, u...", "helpful": [0, 0], "reviewText": "Not much ...despite their pricing,", "overall": 5.0, "summary": "good", "unixReviewTime": 1393545600, "reviewTime": "02 28, 2014"}
{"reviewerID": "A14VAT5EAX3D9S", "asin": "1384719342", "reviewerName": "Jake", "helpful": [13, 14], "reviewText": "The product ...this product! :]", "overall": 5.0, "summary": "Jake", "unixReviewTime": 1363392000, "reviewTime": "03 16, 2013"}
{"reviewerID": "A195EZSQDW3E21", "asin": "1384719342", "reviewerName": "Rick Bennette \"Rick Bennette\"", "helpful": [1, 1], "reviewText": "The primary... you put it.", "overall": 5.0, "summary": "It Does The Job Well", "unixReviewTime": 1377648000, "reviewTime": "08 28, 2013"}


这个东西,我是这样读的

library(rjson)
data = fromJSON(file = 'Musical_instruments_5.json')

但是结果只有最后一行,就是data的数据不全


我修改json文件之后,再这样读,就是列表嵌套的格式了

12
bbslover 在职认证  发表于 2017-3-13 08:18:40
Reduce函数   Map函数  都很好

13
cheetahfly 在职认证  发表于 2017-3-15 13:24:11
library(purrr)
scores %>% transpose() %>% map(unlist)

14
屋檐滴语 发表于 2018-7-24 17:53:35
cheetahfly 发表于 2017-3-15 13:24
library(purrr)
scores %>% transpose() %>% map(unlist)
谢谢你的解决方案,很有启发!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 02:12