jsonlite

how do you extract data from nested json data in R

心不动则不痛 提交于 2019-12-12 02:52:50
问题 I need to be able to extract these fields from this file that has many json entries: sender: Hostname mem:used_p cpu: user_p load: load_5 // cat tmp.txt {"senderDateTimeStamp":"2016-04-07T00:00:00.0093","senderHost":"server1","senderAppcode":"test_infrastats_prod","senderUsecase":"system","destinationTopic":"test_serverstats_realtimedata_topic_prod","correlatedRecord":false,"needCorrelationCacheCleanup":false,"needCorrelation":false,"correlationAttributes":null,"correlationRecordCount":0,

combining many data frames with rbind and pages

谁说胖子不能爱 提交于 2019-12-11 17:28:17
问题 I am trying to rbind pages sequentially by combining the data frames using the pages. library(jsonlite) pages <- list() for(i in 1:3){ mydata<- data.frame(c(1,2), c(4,5)) pages[[i+1]] <- mydata$filings } filings <- rbind.pages(pages) When i view the filings dataset I see only 0 variables. I am expecting 6 rows and 2 columns. Can some one address how to tether and attach the data while looping. Thanks 来源: https://stackoverflow.com/questions/30539282/combining-many-data-frames-with-rbind-and

Can't use jsonlite in R to read json format file

耗尽温柔 提交于 2019-12-11 15:24:16
问题 I can't use R to read the .json file, but I can see it on the web site. Below is the site of data↓ https://data.kcg.gov.tw/dataset/7999ac19-e7dc-496a-9b7d-bd8daec107bd/resource/19d06299-a80c-42c2-a9b8-63d4466161a0/download/priceshistory20160101-20161231.json Here is my code. library(jsonlite) link <- "https://data.kcg.gov.tw/dataset/7999ac19-e7dc-496a-9b7d-bd8daec107bd/resource/19d06299-a80c-42c2-a9b8-63d4466161a0/download/priceshistory_20160101-20161231.json" kh <- fromJSON(link) Error in

How to loop - JSONP / JSON data using R

空扰寡人 提交于 2019-12-11 10:05:50
问题 I thought I had parsed the data correctly using jsonlite & tidyjson . However, I am noticing that only the data from the first page is being parsed. Please advice how I could parse all the pages correctly. The total number of pages are over 1300 -if I look at the json output, so I think the data is available but not correctly parsed. Note: I have used tidyjson , but am open to using jsonlite or any other library too. library(dplyr) library(tidyjson) library(jsonlite) req <- httr::GET("http:/

How to pass a variable in url in fromJSON command

爷,独闯天下 提交于 2019-12-11 08:53:30
问题 I am trying to pass a variable in the url and flatten using jsonlite, but i am not able to pass variable pages using the loop. How do i loop using FromJSON? pages<- list() for(i in 1:20) { mydata <- fromJSON("https:www.example.com/page="+i+"&access_token=xyz", flatten = TRUE) } filings <-rbind.pages(pages) 回答1: What about this? pages<- list() for(i in 1:20) { mydata <- fromJSON(paste("https:www.example.com/page=", i, "&access_token=xyz", sep = "+"), flatten = TRUE) } filings <-rbind.pages

How to flatten nested data frames returned from jsonlite

柔情痞子 提交于 2019-12-11 03:15:44
问题 I am loading this JSON data with jsonlite <snip> "rawData": { "fortune": {}, "plaintext": {}, "db": {}, "update": { "duda": [ { "latencyAvg": "201.40us", "latencyMax": "727.00us", "latencyStdev": "54.85us", "totalRequests": 561810, "startTime": 1413890149, "endTime": 1413890164 } ] }, "json": { "duda": [ { "latencyAvg": "201.40us", "latencyMax": "727.00us", "latencyStdev": "54.85us", "totalRequests": 561810, "startTime": 1413890149, "endTime": 1413890164 } ] }, "query": {} } Which results in

How to parse a file with stacked multiple JSONs in R?

怎甘沉沦 提交于 2019-12-10 17:29:58
问题 I have the following "stacked JSON" object within R, example1.json : {"ID":"12345","Timestamp":"20140101", "Usefulness":"Yes", "Code":[{"event1":"A","result":"1"},…]} {"ID":"1A35B","Timestamp":"20140102", "Usefulness":"No", "Code":[{"event1":"B","result":"1"},…]} {"ID":"AA356","Timestamp":"20140103", "Usefulness":"No", "Code":[{"event1":"B","result":"0"},…]} These are not comma-separated. The fundamental goal would be to parse certain fields (or all fields) into an R data.frame or data.table:

Successfully coercing paginated JSON object to R dataframe

余生颓废 提交于 2019-12-10 13:35:55
问题 I am trying to convert JSON pulled from an API into a data frame in R, so that I can use and analyze the data. #Install needed packages require(RJSONIO) require(httr) #request a list of companies currently fundraising using httr r <- GET("https://api.angel.co/1/startups?filter=raising") #convert to text object using httr raise <- content(r, as="text") #convert to list using RJSONIO fromJSON(raise) -> new Once I get this object, new , I am having a really difficult time parsing the list into a

encoding a JSON expression from R with jsonlite or something else

吃可爱长大的小学妹 提交于 2019-12-07 21:48:24
问题 The API I'm using needs me to send it a JSON message like: y <- '[{"a":1, "b":"select", "c":["A", "B", "C"]}, {"a":2, "b":"text"}, {"a":3, "b":"select", "c":["D", "E", "F", "G"]}]' Notice that in the case "b" : "select" there is another variable c with the value being an array. When I try running fromJSON(y) (in the jsonlite package) I get a data.frame where the 3rd column is a list: > z <- fromJSON(y) > class(z) [1] "data.frame" > z %>% glimpse() Observations: 3 Variables: 3 $ a (int) 1, 2,

JSON (using jsonlite) parsing error in R

懵懂的女人 提交于 2019-12-07 11:47:36
问题 I have the following JSON file: {"id":1140854908,"name":"'Amran"} {"id":1140852651,"name":"'Asir"} {"id":1140855190,"name":"'Eua"} {"id":1140851307,"name":"A Coruna"} {"id":1140854170,"name":"A`Ana"} I used the package jsonlite but I get a parsing error library(jsonlite) try <- fromJSON("states.txt",simplifyDataFrame = T) # Error in feed_push_parser(readBin(con, raw(), n), reset = TRUE) : # parse error: trailing garbage # :1140854908,"name":"'Amran"} {"id":1140852651,"name":"'Asir" # (right