Description Usage Format Examples
From: http://jsonstudio.com/resources/
1 |
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | library(dplyr)
library(jsonlite)
# Print the first record
worldbank[[1]] %>% prettify
# Get the top 10 sectors by funded project in Africa
wb_sectors <- worldbank %>% # 500 Projects funded by the world bank
spread_values(
name = jstring("project_name"), # Spread name
region = jstring("regionname") # Spread region
) %>%
enter_object("majorsector_percent") %>% # Enter the 'sector' object
gather_array("sector.index") %>% # Gather the array
spread_values(sector = jstring("Name")) # Spread the sector name
# Examine the structured data
wb_sectors %>% head
# Get the top 10 sectors by funded project in Africa
wb_sectors %>%
filter(region == "Africa") %>% # Filter to just Africa
group_by(sector) %>% # Group by sector
tally() %>% # Count funded projects
arrange(desc(n)) %>% # Arrange descending
top_n(10) # Take the top 10
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.