append_values: Appends all values with a specified type as a new column

Description Usage Arguments Details Examples

Description

The append_values_X functions let you take any remaining JSON and add it as a column X (for X in "string", "number", "logical") insofar as it is of the JSON type specified.

Usage

1
2
3
4
5
6
7
8
append_values_string(x, column.name = type, force = TRUE,
  recursive = FALSE)

append_values_number(x, column.name = type, force = TRUE,
  recursive = FALSE)

append_values_logical(x, column.name = type, force = TRUE,
  recursive = FALSE)

Arguments

x

a tbl_json object

column.name

the column.name to append the values into the data.frame under

force

parameter that determines if the variable type should be computed or not if force is FALSE, then the function may take more memory

recursive

logical indicating whether to extract a single value from a nested object. Only used when force = TRUE. If force = FALSE, and recursive=TRUE, throws an error.

Details

Any values that do not conform to the type specified will be NA in the resulting column. This includes other scalar types (e.g., numbers or logicals if you are using append_values_string) and *also* any rows where the JSON is still an object or an array.

Examples

1
2
3
4
library(magrittr)  # for %>%
'{"first": "bob", "last": "jones"}' %>%
  gather_keys() %>%
  append_values_string()

sailthru/tidyjson documentation built on May 29, 2019, 12:59 p.m.