Created
July 14, 2018 14:20
-
-
Save andrewbtran/cad0673cdd4cf527f6781a94f597bd0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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