## ----include = FALSE---------------------------------------------------------- # chunks that download hosted data are skipped on CRAN machines; set # NOT_CRAN=true (as the pkgdown workflow does) to evaluate everything NOT_CRAN <- identical(Sys.getenv("NOT_CRAN"), "true") knitr::opts_chunk$set( message = FALSE, warning = FALSE, eval = NOT_CRAN ) ## ----setup, include = FALSE, eval = TRUE-------------------------------------- library(edfinr) library(dplyr) library(ggplot2) ## ----eval = FALSE------------------------------------------------------------- # library(edfinr) # library(dplyr) # library(ggplot2) ## ----example-1---------------------------------------------------------------- # ky_sy23 <- get_finance_data(yr = "2023", geo = "KY") # glimpse(ky_sy23) ## ----example-2---------------------------------------------------------------- # ky_full_sy23 <- get_finance_data(yr = "2023", geo = "KY", dataset_type = "full") # setdiff(names(ky_full_sy23), names(ky_sy23)) ## ----finding-variables, eval = TRUE------------------------------------------- vars <- list_variables("full") vars # filter by category list_variables("full", category = "debt") ## ----example-3---------------------------------------------------------------- # sec_data <- get_finance_data( # yr = "2019:2023", # years 2019 through 2023 # geo = "AL,AR,FL,GA,KY,LA,MS,MO,OK,SC,TN,TX" # comma-separated state codes # ) # # us_sy23 <- get_finance_data(yr = "2023", geo = "all") ## ----caching, eval = FALSE---------------------------------------------------- # # re-download even if a cached copy exists, without progress messages # ky_fresh <- get_finance_data(yr = "2023", geo = "KY", refresh = TRUE, quiet = TRUE) ## ----analysis-1, fig.width = 7, fig.height = 5, fig.alt = "Scatterplot of Connecticut districts' local share of revenue versus total revenue per-pupil for SY2022-23, with point size showing enrollment and color showing urbanicity; the most locally-reliant districts tend to have higher total revenue per-pupil."---- # ct_sy23 <- get_finance_data(yr = "2023", geo = "CT") # # ggplot(ct_sy23) + # geom_point(aes( # x = rev_local / rev_total, # y = rev_total_pp, # color = urbanicity, # size = enroll), # alpha = .6) + # scale_size_area( # max_size = 10, # labels = scales::label_comma() # ) + # scale_x_continuous(labels = scales::label_percent()) + # scale_y_continuous(labels = scales::label_dollar()) + # labs( # title = "Connecticut Districts' Local Revenue Share vs. Total Revenue Per-Pupil, SY2022-23", # x = "Local Share of Total Revenue", # y = "Total Revenue Per-Pupil", # size = "Enrollment", # color = "Urbanicity") + # theme_bw() ## ----analysis-2--------------------------------------------------------------- # # compare revenue mix across urbanicity groups (dollar-weighted) # revenue_analysis <- ct_sy23 |> # group_by(urbanicity) |> # summarize( # pct_local = sum(rev_local, na.rm = TRUE) / sum(rev_total, na.rm = TRUE), # pct_state = sum(rev_state, na.rm = TRUE) / sum(rev_total, na.rm = TRUE), # pct_federal = sum(rev_fed, na.rm = TRUE) / sum(rev_total, na.rm = TRUE), # n_districts = n(), # enrollment = sum(enroll, na.rm = TRUE) # ) # # revenue_analysis