Dealing with multiple JSON result sets in R -


i'm trying json data of nba box scores. issue i'm having json data box score has 3 result sets , care 1 of them.

test<- "http://stats.nba.com/stats/boxscoretraditionalv2?endperiod=10&        endrange=14400&gameid=0021500580&rangetype=2&season=2015-16&        seasontype=regular+season&startperiod=1&startrange=0000"  library(jsonlite)  json_data <- fromjson(paste(readlines(test), collapse="")) str(json_data) 

i care result set name "playerstats" , want make dataframe of it. i'm not sure how specify or exclude other 2 result sets. if me out question great!

you try this, worked me:

df <- data.frame( json_data$resultsets[ 1 , "rowset" ] )  names(df) <- unlist( json_data$resultsets[ 1 , "headers" ] ) 

when working lists can use $ in order dig down lower levels.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -