Skip to content

Instantly share code, notes, and snippets.

@andrewbtran
Created July 14, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewbtran/cad0673cdd4cf527f6781a94f597bd0c to your computer and use it in GitHub Desktop.
Save andrewbtran/cad0673cdd4cf527f6781a94f597bd0c to your computer and use it in GitHub Desktop.
---
title: "Chunk 4"
output: html_document
---
```{r loading, warning=F, message=F, echo=F}
# load packages
library(tidyverse)
# Loading the Boston city payroll
payroll <- read_csv("data/bostonpayroll2013.csv")
# Cleaning up column names
colnames(payroll) <- make.names(colnames(payroll))
# Cleaning out dollar signs and commas so it'll convert to numbers correctly
payroll$TOTAL.EARNINGS <- gsub("\\$", "", payroll$TOTAL.EARNINGS)
payroll$TOTAL.EARNINGS <- gsub(",", "", payroll$TOTAL.EARNINGS)
payroll$TOTAL.EARNINGS <- as.numeric(payroll$TOTAL.EARNINGS)
# Narrowing down the scope of the data
payroll_total <- select(payroll, NAME, TITLE, DEPARTMENT, TOTAL.EARNINGS)
most_pay <- payroll_total %>%
arrange(desc(TOTAL.EARNINGS)) %>%
head(1)
```
The Boston city employee who was paid the most in 2014 was a `r most_pay$TITLE` at `r most_pay$DEPARTMENT`.
This person made $`r prettyNum(most_pay$TOTAL.EARNINGS,big.mark=",",scientific=FALSE)`.
```{r display_data, warning=F, message=F, echo=F}
library(DT)
datatable(payroll_total)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment