Global GNI in a Treeplot

Reasoning: My graphic depicts the continents in specific areas. The acronym for each State or Country is then given on a square relative to the size of its population. The depth of blue color is to describe its GNI in that State or Country. I also think the color blue is a good background for a smaller font.

#install.packages("treemap")
library(RColorBrewer)
data <- readRDS("gni2014.Rda")
library(treemap)
treemap(data,
        index=c("continent", "iso3"),
        vSize="population",
        vColor="GNI",
        type="value",
        palette="RdBu",
        title = "GNI2014",
        fontsize.title = 14,
        format.legend = list(scientific = FALSE, big.mark = " "))

History of US Open golf tournament, US winners & Repeat champions

#to access this data will first need to have the file Midterm2_2.csv, which at this time I do not know how to upload. I made it by copy,pasting, and formatting the US Open info from Wiki.
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
MyData <- read.csv(file="Midterm2_2.csv", header=TRUE, sep=",", skip = 1)
keeps <- c("Year","Country","Champion","Multiple.wins", "Total.score")
Data1 = MyData[keeps]
Data1[is.na(Data1)] <- 0
finaldata <- Data1[1:124,]
tail(MyData)
##     Year       Country       Champion Multiple.wins Total.score
## 119 2013       England    Justin Rose            NA         281
## 120 2014       Germany  Martin Kaymer            NA         271
## 121 2015 United States  Jordan Spieth            NA         275
## 122 2016 United States Dustin Johnson            NA         276
## 123 2017 United States  Brooks Koepka             1         272
## 124 2018 United States  Brooks Koepka             1         281
# Highlight USA colors
fill_colors <- c()
for ( i in 1:length(finaldata$Country) ) {
  if (finaldata$Country[i] == "United States") {
    fill_colors <- c(fill_colors, "#821122")
  } else {
    fill_colors <- c(fill_colors, "#cccccc")
  }
}

barplot(finaldata$Total.score,  names.arg=finaldata$Year, col=fill_colors, border=NA, xlab="Year", ylab="Total Score")

# Highlight Multiple Championship Titles
fill_colors <- c()
for ( i in 1:length(finaldata$Multiple.wins) ) {
  if (finaldata$Multiple.wins[i] == 1) {
    fill_colors <- c(fill_colors, "#821122")
  } else {
    fill_colors <- c(fill_colors, "#cccccc")
  }
}

barplot(finaldata$Total.score,  names.arg=finaldata$Year, col=fill_colors, border=NA, xlab="Year", ylab="Total Score")

Finding White Noise in AirPassenger data

Reasoning: The final plot is what I have rendered from taking the difference from the standard plot from its seasonal trend. I used the #forecast package for ease of use. It also allows for someone with limited statistical knowledge to know how many differences are left with the #ndiffs function.

data(AirPassengers)

plot(AirPassengers, type="l", ylab="Airline Ticket Sales")#plot1

plot(decompose(AirPassengers, "multiplicative"))#plot2

acf(AirPassengers)#plot3

pacf(AirPassengers)#plot4

library(forecast)

#nsdiffs(AirPassengers)-use ndiffs to see how many differnces are needed, continue as needed.
#[1] 1 = start.
diff.seasonal <- diff(AirPassengers, lag=frequency(AirPassengers), differences=1)
#ndiffs(diff.1)
#[1] 1 = keep going.
plot(diff.seasonal)#plot5

white.noise <- diff(diff.seasonal, differences= 1)
#ndiffs(white.noise)
#[1] 0 = is my cue to stop!
plot(white.noise, type="l", main="White Noise")#plot6

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.