library(httr)
library(jsonlite)
res <- GET("https://api.teleport.org/api/urban_areas/slug:prague/scores/")
res_up = fromJSON(rawToChar(res$content))
fes <- GET("https://api.teleport.org/api/urban_areas/slug:san-francisco-bay-area/scores/")
fes_up = fromJSON(rawToChar(fes$content))
sanfranliv = (fes_up$categories$score_out_of_10[2])
prahaliv = (res_up$categories$score_out_of_10[2])
sanfranqual = fes_up$teleport_city_score
prahaqual = res_up$teleport_city_score
Cities = c("Prague", "Bay Area")
Quality_of_Life = c(prahaqual/prahaliv, sanfranqual/sanfranliv)
graph_data = data.frame(Cities, Quality_of_Life)
library(ggplot2)
theme_set(theme_bw())
# Draw plot
ggplot(graph_data, aes(x=Cities, y=Quality_of_Life) ,aes(col=Cities)) +
geom_bar(stat="identity", width=.5,aes(fill=Cities)) +
labs(title="Quality of Life compared to Cost Of Living in Prague vs The Bay Area",
subtitle="Cost of living is measured with a higher score bieng better therefore the smaller the ratio the better",
caption="source: Teleport API",
y= "Quality of Life score divided by Cost of Living score")+
theme(axis.text.x = element_text(angle=65, vjust=0.6))