2023-07-11
README.md
file can help you stay organized and keep track of data sources and/or outliers.File -> New Project...
, but it’s more difficult to connect it to Github if you start that way.Building a consistent file structure in your projects will help you (and others!) easily navigate your code.
Minimally, you will want to have a separate folder for:
data
scripts
figures
/data
folder to keep your raw data files separated from any processed data files you produce during your analysis./processed
data folder for exporting clean data or results of your analysis, like summary tables.source("path/to/some/file.R")
to run scripts you’ve written behind-the-scenes, giving you access to the objects created by that script.# 2_f33_2008_2013_clean
# 2022-10-05 last updated by Krista Kaput
# load -----
library(tidyverse)
library(readxl)
options(scipen = 999)
# source script cleaning f33 data from 2002-2007
source("f33_finance_enrollment_scripts/1_f33_2002_2007_clean.R")
# load raw f33 from 2008
f33_2008_raw <- read_excel("raw_data/f33_finance_raw/elsec08_sttables.xls",
sheet = "1", skip = 9, n_max = 53)
# load raw f33 from 2009
f33_2009_raw <- read_excel("raw_data/f33_finance_raw/elsec09_sttables.xls",
sheet = "1", skip = 9, n_max = 53)
# load raw f33 from 2010
f33_2010_raw <- read_excel("raw_data/f33_finance_raw/elsec10_sttables.xls",
sheet = "1", skip = 9, n_max = 53)
# load raw f33 from 2011
f33_2011_raw <- read_excel("raw_data/f33_finance_raw/elsec11_sttables.xls",
sheet = "1", skip = 9, n_max = 53)
# load raw f33 from 2012
f33_2012_raw <- read_excel("raw_data/f33_finance_raw/elsec12_sttables.xls",
sheet = "1", skip = 7, n_max = 53)
# load raw f33 from 2013
f33_2013_raw <- read_excel("raw_data/f33_finance_raw/elsec13_sttables.xls",
sheet = "1", skip = 7, n_max = 53)
# clean all 2008 f33 data ---------
f33_2008_all <- f33_2008_raw |>
rename(state = "...1",
total_revenue = "Total Revenue",
federal_revenue = "Federal Revenue",
state_revenue = "State Revenue",
local_revenue = "Local Revenue",
total_expenditures = "Total Expenditure",
current_expenditures = "Current Spending",
capital_expenses = "Capital Outlay") |>
mutate(year = 2008) |>
select(year, state, total_revenue, federal_revenue, state_revenue, local_revenue,
total_expenditures, current_expenditures, capital_expenses)
# filter for 2008 national f33 data
f33_2008_us <- f33_2008_all |>
filter(total_revenue == "582125621")
# filter for 2008 state f33 data
f33_2008_states <- f33_2008_all |>
filter(total_revenue != "582125621")
# clean all 2009 f33 data ---------
f33_2009_all <- f33_2009_raw |>
rename(state = "...1",
total_revenue = "Total Revenue",
federal_revenue = "Federal Revenue",
state_revenue = "State Revenue",
local_revenue = "Local Revenue",
total_expenditures = "Total Expenditure",
current_expenditures = "Current Spending",
capital_expenses = "Capital Outlay") |>
mutate(year = 2009) |>
select(year, state, total_revenue, federal_revenue, state_revenue, local_revenue,
total_expenditures, current_expenditures, capital_expenses)
# filter for 2009 national f33 data
f33_2009_us <- f33_2009_all |>
filter(total_revenue == "590947579")
# filter for 2009 state f33 data
f33_2009_states <- f33_2009_all |>
filter(total_revenue != "590947579")
# clean all 2010 f33 data ------------
f33_2010_all <- f33_2010_raw |>
rename(state = "...1",
total_revenue = "Total Revenue",
federal_revenue = "Federal Revenue",
state_revenue = "State Revenue",
local_revenue = "Local Revenue",
total_expenditures = "Total Expenditure",
current_expenditures = "Current Spending",
capital_expenses = "Capital Outlay") |>
mutate(year = 2010) |>
select(year, state, total_revenue, federal_revenue, state_revenue, local_revenue,
total_expenditures, current_expenditures, capital_expenses)
# filter for 2010 national f33 data
f33_2010_us <- f33_2010_all |>
filter(total_revenue == "592895329")
# filter for 2010 state f33 data
f33_2010_states <- f33_2010_all |>
filter(total_revenue != "592895329")
# clean all 2011 f33 data ------------
f33_2011_all <- f33_2011_raw |>
rename(state = "...1",
total_revenue = "Total Revenue",
federal_revenue = "Federal Revenue",
state_revenue = "State Revenue",
local_revenue = "Local Revenue",
total_expenditures = "Total Expenditures",
current_expenditures = "Current Spending",
capital_expenses = "Capital Outlay") |>
mutate(year = 2011) |>
select(year, state, total_revenue, federal_revenue, state_revenue, local_revenue,
total_expenditures, current_expenditures, capital_expenses)
YAML Header: Controls certain output settings that apply to the entire document.
Code Chunk: Includes code to run, and code-related options.
Body Text: For communicating results and findings to the targeted audience.
Code to Generate a Table: Outputs a table with minimal formatting like you would see in the console.
Section Header: Specified with ##
.
Code to Generate a Plot: Outputs a plot. Here, the code used to generate the plot will not be included because the parameter echo=FALSE
is specified.
R code chunks in R Markdown are contained within a pair of triple backticks that include a curly brace that indicates the section contains r code:
```{r}
<code goes here>
```
Markdown is a *really* easy way to format text. For more, visit Markdown Guide).
For more on using R Markdown documents, check out RStudio’s resources here.
Use the Render button to render the file and preview the output with a single click or keyboard shortcut (⇧⌘K)
You can also automatically render whenever you save. To do that you check the Render on Save option on the editor toolbar. The preview will update whenever you re-render the document. Side-by-side preview works for both HTML and PDF outputs.
When rendering, Quarto generates a new file that contains selected text, code, and results from the .qmd file. The new file can be an HTML, PDF, MS Word document, presentation, website, book, interactive document, or other format.
Reading assignment
Coding task
week04
assignment!Finance contact