Skip to content

Instantly share code, notes, and snippets.

@andrewbtran andrewbtran/Chunk 4
Created Jul 14, 2018

Embed
What would you like to do?
---
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
You can’t perform that action at this time.