For the fantasy draft, we wanted to look at numerous different factors. One factor that we explored was whether or not our players had a increasing or a decreasing trend across the season. This code was used for each player (with the csv path file replaced).
library(tidyverse) #collection of libraries that contains ggplot2 and is used constantly throughout R users
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.3 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.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
df <-read.csv("C:/Users/muril/Downloads/Fantasy Draft - Tetairoa McMillan.csv")#importing dataset df <- df %>%group_by(Season) #group by season to display each one as its own graph df$Game.Day <-as.Date(df$Game.Day, format ="%m/%d/%y") #change formatting of date, as it is different from world wide df %>%ggplot(aes(x = Game.Day, y = Points)) +geom_point() +geom_smooth() +facet_wrap(~Season, scales ="free_x") #wrap to give free x axis across seasons and also display a separate graph for each season
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'