1234567891011121314151617181920212223242526272829303132333435363738 |
- library(tidycensus)
- library(tidyverse)
- library(plumber)
-
-
- #* Call table
- #* @get /table
- #* @serializer json
- callData = function(table,municipality) {
-
- census_api_key("7a853acf81fd5758228680556ac831138c40b83e")
- #year is between 2000 and 2020
- #table is dp02pr, dp03, dp04, dp05
-
- #load variables
- variables = load_variables(2020,"acs5/profile")
- #load variable vectors
- codes = variables$name
- codesBool = startsWith(codes,table)
-
- codes = codes[codesBool]
- labels = variables$label[codesBool]
-
- #pull table
- bigTable = get_acs(geography = "county",
- state = "PR",
- year = 2020,
- county = municipality,
- survey = "acs5",
- variables = codes)
-
- bigTable$Label = labels
- bigTable = bigTable[c("Label","estimate","moe")]
- return(bigTable)
- }
-
-
|