- 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.
推薦閱讀
- 腦動力:C語言函數(shù)速查效率手冊
- 分布式多媒體計算機系統(tǒng)
- Pig Design Patterns
- 人工智能實踐錄
- Enterprise PowerShell Scripting Bootcamp
- 計算機硬件技術(shù)基礎(chǔ)學(xué)習(xí)指導(dǎo)與練習(xí)
- 51單片機應(yīng)用程序開發(fā)與實踐
- 單片機C51應(yīng)用技術(shù)
- 大數(shù)據(jù):從基礎(chǔ)理論到最佳實踐
- 工業(yè)機器人技術(shù)
- 從實踐中學(xué)嵌入式Linux操作系統(tǒng)
- Mastering Windows Group Policy
- 機器人系統(tǒng)設(shè)計與制作:Python語言實現(xiàn)(原書第2版)
- Learning Elastic Stack 6.0
- 操作系統(tǒng)及網(wǎng)絡(luò)應(yīng)用技術(shù)