data-raw/process_categories.R

library(jsonlite)
library(data.tree)

rm(list = ls())

file <- system.file("extdata", "categories.json", package = "gtrendsR")

res <- fromJSON(file, simplifyDataFrame =  FALSE)

res <- as.Node(res)

categories <- ToDataFrameTree(res, "name", "id")
categories <- na.omit(categories)
categories <- categories[, c("name", "id")]
categories$name <- iconv(categories$name, to = "ASCII//TRANSLIT")
categories$id <- as.character(categories$id)

devtools::use_data(categories, overwrite = TRUE)
cemigo114/GoogleAPI documentation built on May 12, 2017, 1:16 a.m.