****Load the required libraries ***

library(tidyverse)
library(openintro)
library(dplyr)

Activity 1

Load the data and get the summary of this data **************************************************************** 1) Read data from transfers.csv 2) Get row and columns of this data set–it has 932 rows and 5 columns(variables) 3) Get the summary of this data 4) print the data of this set

chessdata <- read.table("https://raw.githubusercontent.com/fivethirtyeight/data/master/chess-transfers/transfers.csv",sep=",", header=T,  stringsAsFactors=FALSE,quote="", fill=FALSE)

dim(chessdata)
## [1] 932   5
summary(chessdata)
##      url                  ID            Federation          Form.Fed        
##  Length:932         Min.   :  100919   Length:932         Length:932        
##  Class :character   1st Qu.: 1382838   Class :character   Class :character  
##  Mode  :character   Median : 4183150   Mode  :character   Mode  :character  
##                     Mean   : 7861685                                        
##                     3rd Qu.:13601297                                        
##                     Max.   :66200458                                        
##  Transfer.Date     
##  Length:932        
##  Class :character  
##  Mode  :character  
##                    
##                    
## 
head(chessdata)
##                                                  url       ID Federation
## 1 https://ratings.fide.com/fedchange.phtml?year=2000  2019221        USA
## 2 https://ratings.fide.com/fedchange.phtml?year=2000 14401754        BIH
## 3 https://ratings.fide.com/fedchange.phtml?year=2000 14401762        BIH
## 4 https://ratings.fide.com/fedchange.phtml?year=2000  2019221        USA
## 5 https://ratings.fide.com/fedchange.phtml?year=2000 14401754        BIH
## 6 https://ratings.fide.com/fedchange.phtml?year=2000 14401762        BIH
##   Form.Fed Transfer.Date
## 1      PHI      12/15/00
## 2      CRO       1/31/00
## 3      YUG       1/31/00
## 4      PHI      12/15/00
## 5      CRO       1/31/00
## 6      YUG       1/31/00

Activity 2


Shows number of transfers to USA .Total 89 transferred to US.IN USA federation apply column wise subset to select only url,id,From.fed and transfer date as we have already filtered based on US federation . Replaced the short name of USA with “America” for USA subset data set ***********************************************************************

USFederation<-subset(chessdata, Federation == "USA",select= c(url,ID,Federation ,Transfer.Date) ) 
USFederationtotal=table(USFederation$Federation)
summary(USFederation)
##      url                  ID            Federation        Transfer.Date     
##  Length:89          Min.   :  322750   Length:89          Length:89         
##  Class :character   1st Qu.: 3506690   Class :character   Class :character  
##  Mode  :character   Median : 5300363   Mode  :character   Mode  :character  
##                     Mean   :10592149                                        
##                     3rd Qu.:13500511                                        
##                     Max.   :46662464
USFederation$Federation[USFederation$Federation %in% c("USA")] <-"AMERICA"
USFederation$Federation
##  [1] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
##  [8] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [15] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [22] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [29] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [36] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [43] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [50] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [57] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [64] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [71] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [78] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"
## [85] "AMERICA" "AMERICA" "AMERICA" "AMERICA" "AMERICA"

Activity 3


Find how many transfers took place from other countries and note the most transfers that took place from a certain country *********************************************************************

CountryWise_TotalTransfer=table(chessdata$Form.Fed)
CountryWise_TotalTransfer
## 
##     AHO ALB AND ARG ARM AUS AUT AZE BAN BAR BEL BIH BLR BRA BRN BUL CAN CHI CHN 
##   9   1   3   4  11  15   7   6  14   2   1   7  21  13   1   1   7  11   3   8 
## COL CRC CRO CUB CYP CZE DEN EGY ENG ESP EST FID FIN FRA GCI GEO GER GRE HKG HON 
##  10   1  19  24   2   2   8   3  36  27   4   7   3  43   1  15  42   6   3   2 
## HUN IND IRI IRL IRQ ISL ISR ISV ITA JOR KAZ KEN LAT LBN LIE LTU LUX MAR MAS MDA 
##  11  17   9   2   2   1  14   1   6   2   8   1  11   6   3   6   1   1   2  13 
## MGL MKD MNC MNE NCA NED NOR NZL PER PHI PLE POL POR PUR ROM ROU RSA RUS SCG SCO 
##   4   5   3   4   1  13   3   6   4  11   3  13   5   1   5  23   3  75  10   6 
## SIN SLO SMR SRB SRI SUI SVK SWE SYR TKM TPE TTO TUR UKR URU USA UZB VEN VIE YUG 
##   5   5   2  33   2  13  15   4  10   1   1   1   2  60   1  33   8   1   3  12 
## ZAM 
##   2
CountryWiseTransferRation<-CountryWise_TotalTransfer/sum(CountryWise_TotalTransfer)

barplot(CountryWiseTransferRation)

Conclusion drawn


CONCLUSION CAN BE CLEARLY DRAWN THAT MOST TRANSFERS HAPPENED in 2003 FROM RUSSIA *************************************************************************************

maxTransferCountries <- subset(chessdata, (as.Date(chessdata$Transfer.Date,format = "%m/%d/%y") >=1/23/01 & as.Date(chessdata$Transfer.Date,format = "%m/%d/%y" )<= 3/15/10) & chessdata$Form.Fed=="RUS")


chessdata$Transfer.Date<-as.Date(chessdata$Transfer.Date,format="%y")

chessdata$year <- as.numeric(format(chessdata$Transfer.Date, "%Y"))

maxTransferCountries <- subset(chessdata, chessdata$year >=2001 & chessdata$year <= 2010 & chessdata$Form.Fed=="RUS")


federations<-table(maxTransferCountries$year)

federationsRatios<-federations/sum(federations)


barplot(federationsRatios,main="Transfers from Russia  between 2001 and 2010")