I recently created a function that is calling an API and gives the following results (json format):
{"data":{"loc":"google.fr","lang":"fr","domain":"domain.com","result":[["voyage thailande",1,"https://www.blabla.com/thailande/"]]}}
My purpose is to get a data.frame with "only" the last part of the after the "result":
voyage thailande, 0, https://www.blabla.com/thailande/
Right now I only succeeded to get the following data.frame (see the picture):
With the following code:
library(rjson)
keyword_checker <- function(keyword, domain, loc, lang){
keyword_to_check <- as.character(keyword)
api_request <- paste("https://script.fromgoogle.....",
"?kw=",keyword,
"&domain=",domain,
"&loc=",loc,
"&lang=",lang,sep="")
api_request <- URLencode(api_request, repeated = TRUE)
source <-fromJSON(file = api_request)#Convertir un Json file en Data Frame
return(data.frame(do.call("rbind", source)))
}
Thank you for your help