Title: Dodgers
install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(tidyverse)
## ── 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.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── 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
install.packages("completejourney")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(completejourney)
## Welcome to the completejourney package! Learn more about these data
## sets at http://bit.ly/completejourney.
library(ggplot2)
library(lubridate)
ls("package:completejourney")
## [1] "%<-%" "%>%" "campaign_descriptions"
## [4] "campaigns" "coupon_redemptions" "coupons"
## [7] "demographics" "get_data" "get_promotions"
## [10] "get_transactions" "products" "promotions_sample"
## [13] "transactions_sample"
Dodgers <- read.csv("DodgersData.csv")
install.packages("rpart")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(rpart)
Df <- rpart(opponent~., data=Dodgers)
install.packages("visTree")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library("visTree")
install.packages("visNetwork")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library("visNetwork")
##
## Attaching package: 'visNetwork'
## The following object is masked from 'package:visTree':
##
## visTree
install.packages("sparkline")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library("sparkline")
Df <- rpart(attend~., data=Dodgers)
visTree (Df, main = "Dodgers data attendance")
install.packages("ggplot")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning: package 'ggplot' is not available for this version of R
##
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
library(ggplot2)
ggplot(Dodgers, aes(x = as.factor(opponent), y = attend, fill = as.factor(opponent))) +
geom_boxplot() +
scale_fill_viridis_d(name = "attend") +
labs(title = "Dodgers attendance by opponent",
x = "opponent", y = "attendance") +
theme_minimal()