在 R 中以奇怪的 JSON 格式展平嵌套数据帧
您好,我对 JSON 和 R 相当陌生,但我读过很多帖子,但找不到我的问题的答案。 我有带有多个嵌套数据帧的 JSON 数据,其格式是我在此处从未见过的。这是如何使用 field_name 和 field_value 作为变量的示例。
..$ :'data.frame': 2 obs. of 2 variables:
.. ..$ field_name : chr "Staff Type" "Appointment ID"
.. ..$ field_value: chr "TEACHING" ""
..$ :'data.frame': 2 obs. of 2 variables:
.. ..$ field_name : chr "Staff Type" "Appointment ID"
.. ..$ field_value: chr "SENIOR STAFF (ACADEMIC)" ""
我尝试过 flatten() 和各种 unnest、unlist 但它仍然显示为 'list(field_name = c("Staff Type", "Appointment ID"), field_val...'
我似乎有一篇从该数据集派生的帖子,这更符合我期望的格式。
..$ stats:'data.frame': 2 obs. of 3 variables:
.. ..$ speed : num 55 34
.. ..$ weight: num 67 24
.. ..$ drift : num 35 32
任何人都可以帮忙吗?我有负载这些字段中的:-( 谢谢
Hi I am fairly new to JSON and R but I have read numerous posts and cannot find an answer to my issue.
I have JSON data with multiple nested data frames in a format that I have not seen anywhere on here. This is an example of how it is coming through with both the field_name and field_value as variables.
..$ :'data.frame': 2 obs. of 2 variables:
.. ..$ field_name : chr "Staff Type" "Appointment ID"
.. ..$ field_value: chr "TEACHING" ""
..$ :'data.frame': 2 obs. of 2 variables:
.. ..$ field_name : chr "Staff Type" "Appointment ID"
.. ..$ field_value: chr "SENIOR STAFF (ACADEMIC)" ""
I have tried flatten() and various unnest, unlist but it still appears as
'list(field_name = c("Staff Type", "Appointment ID"), field_val...'
I have seem a post derived from this data set and this is more the format I would expect.
..$ stats:'data.frame': 2 obs. of 3 variables:
.. ..$ speed : num 55 34
.. ..$ weight: num 67 24
.. ..$ drift : num 35 32
Can anyone help? I have loads of these fields :-(
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论