{r setup, include=FALSE} library(flexdashboard)
{r} library(DT) library(tidyverse) library(dplyr) library(rvest)
#DATA FOR PLAYER RED
url3<-“https://sports.ndtv.com/english-premier-league/stats/most-red-cards-player-statsdetail/2020-21” r=read_html(url3) %>% html_nodes(“table”) %>% html_table() red=data.frame(r)
redcards=head(red,10) redcards[“average”]=(redcards\(red.card/redcards\)Games.Played) datatable(redcards)
{r} library(DT) library(tidyverse) library(dplyr) library(rvest)
url4<-“https://sports.ndtv.com/english-premier-league/stats/most-red-cards-team-statsdetail/2020-21” tr=read_html(url4) %>% html_nodes(“table”) %>% html_table() teamred=data.frame(tr) teamredcards=head(teamred,10) datatable(teamredcards)
{r}
plot(redcards\(Games.Played,redcards\)red.card,type=“p”,xlab =" games played“, ylab =”red cards“,main=”GAMES PLAYED VS RED CARDS CONCEDED“,col=rainbow(10),pch=19) legend(”topleft",legend = redcards$Player.Name,col = rainbow(10),cex=0.8,fill = rainbow((10)))
{R} plot(redcards\(average,redcards\)Rank,type=“p”,xlab =" red card average per game“, ylab =”ranking“,main=”PLAYER RANKING VS PER GAME REDCARD AVERAGE“,col=rainbow(10),pch=19) legend(”center",legend = redcards$Player.Name,col = rainbow(10),cex=0.5,fill = rainbow((10)))
{r}
#CORRELATION # Data generation set.seed(1) x <- redcards\(average y <- redcards\)Games.Played
plot(x, y,xlab = “Passes”,ylab = “Wins”,main = “RELATIONSHIP BETWEEN PER GAME RED CARD AVERAGE AND GAMES PLAYED”, pch = 19, col = rainbow(10))
abline(lm(y ~ x), col = “red”, lwd = 3)
text(paste(“Correlation:”, round(cor(x, y), 2)), x = 17000, y = 25) cd=cor(x,y)
{r} slices=teamredcards\(red.card names=teamredcards\)Club.Name pct=round(slices/sum(slices)*100) new=paste(names,“-”,pct,“%”,sep="“) pie(slices,labels = new,main =”RED CARDS 20/21(club)",col=rainbow(11:20))