Have you ever wondered which NCAA Division I Men’s lacrosse program has the most championships? Or, how many teams have won a Championship?

Well, look no further!

#All time NCAA Divsion I Men’s Lacross Championship History ##source https://www.ncaa.com/history/lacrosse-men/d1

#setup - setting working directory & importing data 
setwd("~/NYU/classes/2. R")
library(readr)
ncaa <- read_csv("NCAA Lacrosse Champions_Summary.csv")
## Rows: 11 Columns: 2
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): School
## dbl (1): Championships
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
print(ncaa)
## # A tibble: 11 x 2
##    School         Championships
##    <chr>                  <dbl>
##  1 Cornell                    3
##  2 Denver                     1
##  3 Duke                       3
##  4 Johns Hopkins              9
##  5 Loyola (Md.)               1
##  6 Maryland                   3
##  7 North Carolina             5
##  8 Princeton                  6
##  9 Syracuse                  11
## 10 Virginia                   7
## 11 Yale                       1
#How many total programs have one a Championship?
schools=c(ncaa$School)
paste(length(schools),"programs have won an NCAA DI Men's Championship")
## [1] "11 programs have won an NCAA DI Men's Championship"
#what is the most number of championships by any team?
paste("The most number of championships by a team is",max(ncaa$Championships))
## [1] "The most number of championships by a team is 11"
##Which program?
paste("The program with the most championships is", subset(ncaa, ncaa$Championships==11))
## [1] "The program with the most championships is Syracuse"
## [2] "The program with the most championships is 11"
#how many programs have only won 1 championship?
one_champ=subset(ncaa, ncaa$Championships==1)
list_of_one=(one_champ$School)
paste(length(list_of_one),"programs have won 1 championship")      
## [1] "3 programs have won 1 championship"
#Which programs have only won 1 championship?
print(list_of_one)
## [1] "Denver"       "Loyola (Md.)" "Yale"
#Of the programs that have won championships, what is the average number of championships won? 
paste("The average numbrer of championships won is", mean(ncaa$Championships))
## [1] "The average numbrer of championships won is 4.54545454545455"
#see the full breakout of championships by program
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
plot_ly(x=ncaa$School, y=ncaa$Championships,name="D1", type = "bar")