R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

candy <- read.csv("candy_production.csv")

Including Plots

You can also embed plots, for example:

##         Date Candy_Production
## 1 1972-01-01          85.6945
## 2 1972-02-01          71.8200
## 3 1972-03-01          66.0229
## 4 1972-04-01          64.5645
## 5 1972-05-01          65.0100
## 6 1972-06-01          67.6467
##           Date Candy_Production
## 543 2017-03-01         105.2245
## 544 2017-04-01         107.4288
## 545 2017-05-01         101.9209
## 546 2017-06-01         104.2022
## 547 2017-07-01         102.5861
## 548 2017-08-01         114.0613
set.seed(123)
candy_sample <- candy[sample(1:nrow(candy), 274),]
sum(is.na(candy)) 
## [1] 0
candy_sample[[2]] <- as.numeric(candy_sample[[2]])
hist(candy_sample[[2]],
main = "Distribution of U.S. Candy Production",
xlab = "Candy Production Index", 
ylab = "Frequency")

candy_sample[[1]] <- as.Date(candy_sample[[1]])
candy_sample <- candy_sample[order(candy_sample[[1]]), ]
plot(candy_sample[[1]],
     candy_sample[[2]],
     type = "l",
     main = "U.S. Candy Production Over Time",
     xlab = "Year",
     ylab = "Candy Production Index")