- Hands-On Exploratory Data Analysis with R
- Radhika Datar Harish Garg
- 186字
- 2021-06-24 14:10:42
Loading the jsonlite package
The following command is executed to include the jsonlite package in the R workspace:
library(jsonlite)
Data processing or parsing is done through a process called simplification. This is where JSON arrays are converted from a list into a more specific R class. Basically, with a simplification process, the arrays are broken down into values that can be easily understood. There are three different options that can be passed as arguments to the fromJSON function:
- simplifyVector: This option is used to convert arrays into a vector format
- simplifyDataFrame: This option is used to convert arrays into a data frame format with representation of rows and columns
- simplifyMatrix: This is similar to the data frame format, the only difference being that data should be included as a numeric representation
Let's look at an example of a data frame:
json_data <-
'[
{"Name" : "John", "Age" : 42, "City" : "New York"},
{"Name" : "Jane", "Age" : 41, "City" : "Paris"},
{},
{"Name" : "Bob", "City" : "London"}
]'
df <- fromJSON(json_data)
df
Here, json_data key values are converted into a data frame.
推薦閱讀
- 工業(yè)機(jī)器人虛擬仿真實(shí)例教程:KUKA.Sim Pro(全彩版)
- 玩轉(zhuǎn)智能機(jī)器人程小奔
- Visualforce Development Cookbook(Second Edition)
- Managing Mission:Critical Domains and DNS
- 計(jì)算機(jī)原理
- 自動(dòng)控制原理
- Learning Social Media Analytics with R
- PostgreSQL 10 Administration Cookbook
- Godot Engine Game Development Projects
- Excel 2010函數(shù)與公式速查手冊(cè)
- 在實(shí)戰(zhàn)中成長(zhǎng):C++開發(fā)之路
- WOW!Photoshop CS6完全自學(xué)寶典
- 網(wǎng)絡(luò)信息安全項(xiàng)目教程
- Getting Started with Tableau 2019.2
- 網(wǎng)絡(luò)安全原理與應(yīng)用