Learn R Programming

lgrExtra (version 0.1.0)

unpack_json_cols: Unserialize data frame columns that contain JSON

Description

Unserialize data frame columns that contain JSON

Usage

unpack_json_cols(x, cols)

# S3 method for data.table unpack_json_cols(x, cols)

# S3 method for data.frame unpack_json_cols(x, cols)

Value

a data.frame with additional columns expanded from the columns containing JSON

Arguments

x

a data.frame

cols

character vector. The names of the text columns containing JSON strings that should be expanded.

Examples

Run this code
x <- data.frame(
  name = "example data",
  fields = '{"letters":["a","b","c"], "LETTERS":["A","B","C"]}',
  stringsAsFactors = FALSE
)
res <- unpack_json_cols(x, "fields")
res
res$letters[[1]]

Run the code above in your browser using DataLab