#### 1.1. Load packages ####
library(tidyverse) # The tidyverse collection of packages
## ── 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 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
library(httr) # Useful for web authentication
library(rvest) # Useful tools for working with HTML and XML
##
## Attaching package: 'rvest'
##
## The following object is masked from 'package:readr':
##
## guess_encoding
library(lubridate) # Working with dates
library(magrittr) # Piping output easily with loops
##
## Attaching package: 'magrittr'
##
## The following object is masked from 'package:purrr':
##
## set_names
##
## The following object is masked from 'package:tidyr':
##
## extract
library(readr)
#### Intro ####
# I will be scraping reviews off of rate my professor. I will be answering
# who has the best average rating among BAIS Professors.
# To complete this i will scrape rate my professor reviews and sort them into
# a data frame
#### Loading in CSV ####
professor_data <- read_csv("https://myxavier-my.sharepoint.com/:x:/g/personal/fasanab_xavier_edu/IQB0V6Ux3cQJQ6OUZBwXGGVvAV0VNUrIFpnmElQFJMQ2Sz8?download=1")
## Rows: 83 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): professor, course, review
## dbl (2): course_difficulty, rating
## date (1): date
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#### Relationship b/n course difficulty and rating
professor_data %>%
ggplot(aes(x = course_difficulty, y = rating))+
geom_point()+
labs(title = "Relationship b/n course difficulty and rating",
x = "Course Difficulty",
y = "Rating")

# I can conclude that there is no relationship between course difficulty and
# rating because there are no clusters from the data.
#### Visualizing which professor has the highest average professor rating ####
# Average Rating by Professor
professor_data %>%
group_by(professor) %>%
summarise(`AVG Rating per Professor` = mean(rating)) %>%
ggplot(aes(x = professor, y = `AVG Rating per Professor`))+
geom_col()+
labs(title = "Average Rating by Professor",
x = "Professor",
y = "Average Rating")

# From this visual we can conclude that Ramanyake has the highest average rating
# rated by his students.
#### Ratings over time ####
professor_data %>%
ggplot(aes(x = date, y = rating))+
geom_line()+
labs(title = "Ratings over time",
x = "Date",
y = "Rating")

# This visual shows the ratings of professors over time. From 2022-2026
# The ratings do not dop below 3. However, there was a steep drop in 2026
# which comes from Joel's outlier
#### Average Rating and Course Difficulty for the Department ####
professor_data %>%
summarise(`Avg Rating for Dpt` = mean(rating),
`Avg Course Difficulty for Dpt` = mean(course_difficulty))
## # A tibble: 1 × 2
## `Avg Rating for Dpt` `Avg Course Difficulty for Dpt`
## <dbl> <dbl>
## 1 3.36 2.92
#### Histogram of Ratings ####
professor_data %>%
ggplot(aes(x = rating))+
geom_histogram()+
labs(title = "Histogram of Ratings",
x = "Rating",
y = "Frequency")
## `stat_bin()` using `bins = 30`. Pick better value `binwidth`.

# we can see that most professors receive a 5 from their students
# Joel "addicted to discord" review
professor_data %>%
filter(professor == "Joel Asay") %>%
filter(rating == 1)
## # A tibble: 1 × 6
## professor date course course_difficulty rating review
## <chr> <date> <chr> <dbl> <dbl> <chr>
## 1 Joel Asay 2026-09-01 BAIS462 3 1 Joel is addicted to Dis…