The goal of this assignment is to EXTEND a Vignette of a classmate’s CREATE Vignette from the Tidyverse Assignment GitHub Repository.
For this assignment, I am going to EXTEND Atta Boateng’s Vignette. By extending the Vignette below, I will utilize ggplot to plot and customize the color of the plot based on the opening prices of other stock index types from the data.
Below is Atta Boateng’s Vignette:
“Using the data of stock data, I am going to demonstrate some of the capabilities of the tidyverse package. I start by first using the ggplot library to plot the opening prices of the New York Stock Exchange, noted by the symbol (NYA).” - Atta Boateng
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",");
dd <- dd %>% filter(Index == "NYA" );
ggplot(data = dd, aes(x=as.Date(dd$Date) , y=as.numeric(dd$Open))) + geom_line()+ labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
“The ggplot function provides us with various graph options for our dataset. The function has a ‘data’ parameter and ‘mapping’ parameter. Additionally, witht the ‘+’ operators, one the include the type of graph they wish to plot.” - Atta Boateng
I extended Anna’s Vignette by plotting additional index type stocks and added colors to the plot to enhance data visualization.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "HSI")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="red") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "GSPTSE")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="blue") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "NSEI")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="green") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "GDAXI")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="purple") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "KS11")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="orange") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "SSMI")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="darkgreen") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
## Warning: Removed 1 row containing missing values (`geom_line()`).
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "TWII")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="lightpink") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "N225")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="lightblue") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.
dd <- read.csv("https://raw.githubusercontent.com/attaboatengsr/DATA607/main/Week9/indexData.csv", sep=",")
dd <- dd %>% filter(Index == "N100")
ggplot(data = dd, aes(x=as.Date(dd$Date), y=as.numeric(dd$Open))) +
geom_line(color="hotpink") +
labs(x="Date", y="Opening Price")## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `dd$Date` is discouraged.
## ℹ Use `Date` instead.
## Warning: Use of `dd$Open` is discouraged.
## ℹ Use `Open` instead.