#Student participation: 
# Keydy Sanchez 
# Vanessa Wasveiler
# Brian Vargas
#Load your libraries before getting started
library(tidyverse)
## ── Attaching packages ──────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.3
## ✓ tibble  3.0.1     ✓ dplyr   1.0.0
## ✓ tidyr   1.0.2     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ── Conflicts ─────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(stringr)
#(1)Remember that dataset that you found for the first in-class assignment? Pull it up, and classify the columns by data type (the appropriate subcategories for qualitative and quantitative).

#LINK: https://catalog.data.gov/dataset/covid-19-case-surveillance-public-use-data

COVID19_Cases <- read_csv("COVID-19_Cases.csv") 
## Parsed with column specification:
## cols(
##   cdc_report_dt = col_date(format = ""),
##   pos_spec_dt = col_date(format = ""),
##   onset_dt = col_date(format = ""),
##   current_status = col_character(),
##   sex = col_character(),
##   age_group = col_character(),
##   `Race and ethnicity (combined)` = col_character(),
##   hosp_yn = col_character(),
##   icu_yn = col_character(),
##   death_yn = col_character(),
##   medcond_yn = col_character()
## )
#Column Classification: 
#column 1: Continuous  
#column 2: Continuous
#column 3: Continuous
#column 4: nominal
#column 5: nominal
#column 6: Continuous
#column 7: nominal
#column 8: nominal
#column 9: nominal
#column 10: nominal
#column 11: nominal   
#(2) Calculate your estimated grade for the course, individually and then get the average score for your group all using vectors and R.
introduce_yourself <- 2
exams <- c(15, 15)
in_class_assignments_group <- c(5, 5, 5, 5, 5, 5)
in_class_assignments_reflections <- c(1, 1, 1, 1, 1, 1)
final_course_reflection <- 5
data_mining_project_1 <- 15
data_mining_project_2 <- 18

in_class_assignments_names <- c("introduce_yourself", "exams", "in_class_assignments_group", "in_class_assignments_reflections", "final_course_reflection", "data_mining_project")

keydy_sanchez <- c(2, 25, 23, 5, 5, 13, 14)
vanessa_wasveiler <- c(2, 29, 23, 5, 5, 15, 17)
brian_vargas <- c(2, 26, 23, 5, 5, 14, 16)

grade_evaluation_matrix <- rbind(keydy_sanchez, vanessa_wasveiler, brian_vargas)

sum_keydy <- sum(grade_evaluation_matrix[1, 1:7])
sum_vanessa <- sum(grade_evaluation_matrix[2, 1:7])
sum_brian <- sum(grade_evaluation_matrix[3, 1:7])

sum_grades <- c(sum_keydy, sum_vanessa, sum_brian)
grade_average <- mean(sum_grades)

cat("\nThe Average Grade is: ", grade_average)
## 
## The Average Grade is:  91.33333
cat("\nThe Grade for Keydy Sanchez is: ", sum_keydy)
## 
## The Grade for Keydy Sanchez is:  87
cat("\nThe Grade for Vanessa Wasveiller is: ", sum_vanessa)
## 
## The Grade for Vanessa Wasveiller is:  96
cat("\nThe Grade for Brian Vargas is: ", sum_brian)
## 
## The Grade for Brian Vargas is:  91
#Create a basic control structure for grade calculations.
Keydy_Grade <- if(sum_keydy >= 95) { "A" 
  } else if (sum_keydy < 94 & sum_keydy >= 90) { "A-"
  } else if (sum_keydy < 89 & sum_keydy >= 87) { "B+"
  } else if (sum_keydy < 86 & sum_keydy >= 83) { "B"
  } else if (sum_keydy < 82 & sum_keydy >= 80) { "B-"
  } else if (sum_keydy < 79 & sum_keydy >= 77) { "C+"
  } else if (sum_keydy < 76 & sum_keydy >= 70) { "C"
  } else if (sum_keydy < 69 & sum_keydy >= 60) { "D"
  } else {"Something lower than a F"}

Vanessa_Grade <- if(sum_vanessa >= 95) { "A" 
  } else if (sum_vanessa < 94 & sum_vanessa >= 90) { "A-"
  } else if (sum_vanessa < 89 & sum_vanessa >= 87) { "B+"
  } else if (sum_vanessa < 86 & sum_vanessa >= 83) { "B"
  } else if (sum_vanessa < 82 & sum_vanessa >= 80) { "B-"
  } else if (sum_vanessa < 79 & sum_vanessa >= 77) { "C+"
  } else if (sum_vanessa < 76 & sum_vanessa >= 70) { "C"
  } else if (sum_vanessa < 69 & sum_vanessa >= 60) { "D"
  } else {"Something lower than a F"}

Brian_Grade <- if(sum_brian >= 95) { "A" 
  } else if (sum_brian < 94 & sum_brian >= 90) { "A-"
  } else if (sum_brian < 89 & sum_brian >= 87) { "B+"
  } else if (sum_brian < 86 & sum_brian >= 83) { "B"
  } else if (sum_brian < 82 & sum_brian >= 80) { "B-"
  } else if (sum_brian < 79 & sum_brian >= 77) { "C+"
  } else if (sum_brian < 76 & sum_brian >= 70) { "C"
  } else if (sum_brian < 69 & sum_brian >= 60) { "D"
  } else {"Something lower than a F"}

cat("\nThe Letter Grade for Keydy is: ", Keydy_Grade)
## 
## The Letter Grade for Keydy is:  B+
cat("\nThe Letter Grade for Vanessa is: ", Vanessa_Grade)
## 
## The Letter Grade for Vanessa is:  A
cat("\nThe Letter Grade for Brian is: ", Brian_Grade)
## 
## The Letter Grade for Brian is:  A-
# Create a basic function that creates any type of graph for the following dataset.

create_histogram <- function(x) {
  
  ggplot(data = mpg) +
    aes(x = x, fill = x) +
     geom_histogram(bins = 30) +
     theme(axis.text.x = element_text(face = "bold", angle = 90)) +
  theme(legend.position = "year") +
  ylab("Count")
  
}

create_histogram(mpg$displ)

create_histogram(mpg$cty)

create_histogram(mpg$hwy)