#Import "readr" library
library(readr)
#check the current working directory and change it to where scores.csv file was saved
getwd()
## [1] "C:/Users/ajays/Desktop/New England/R - Data Science/Week 2"
setwd("C:\\Users\\ajays\\Desktop\\New England\\R - Data Science\\Week 2")
# Read the scores.csv file
scores<-read_csv("scores.csv")
##
## -- Column specification --------------------------------------------------------
## cols(
## match_id = col_double(),
## match_date = col_character(),
## match_time = col_time(format = ""),
## home_country = col_character(),
## home_code = col_character(),
## home_goals = col_double(),
## away_country = col_character(),
## away_code = col_character(),
## away_goals = col_double(),
## win_country = col_character(),
## win_code = col_character()
## )
# Print the first five rows of the data file
head(scores)
## # A tibble: 6 x 11
## match_id match_date match_time home_country home_code home_goals away_country
## <dbl> <chr> <time> <chr> <chr> <dbl> <chr>
## 1 1 12 June 21:00 Brazil BRA 3 Croatia
## 2 2 13 June 17:00 Mexico MEX 1 Cameroon
## 3 3 13 June 20:00 Spain ESP 1 Netherlands
## 4 4 13 June 23:00 Chile CHI 3 Australia
## 5 5 14 June 17:00 Colombia COL 3 Greece
## 6 6 14 June 23:00 Ivory Coast CIV 2 Japan
## # ... with 4 more variables: away_code <chr>, away_goals <dbl>,
## # win_country <chr>, win_code <chr>
# To print all columns int the dataset
scores_two <- scores[1:5,]
print(scores_two, width = Inf)
## # A tibble: 5 x 11
## match_id match_date match_time home_country home_code home_goals away_country
## <dbl> <chr> <time> <chr> <chr> <dbl> <chr>
## 1 1 12 June 21:00 Brazil BRA 3 Croatia
## 2 2 13 June 17:00 Mexico MEX 1 Cameroon
## 3 3 13 June 20:00 Spain ESP 1 Netherlands
## 4 4 13 June 23:00 Chile CHI 3 Australia
## 5 5 14 June 17:00 Colombia COL 3 Greece
## away_code away_goals win_country win_code
## <chr> <dbl> <chr> <chr>
## 1 CRO 1 Brazil BRA
## 2 CMR 0 Mexico MEX
## 3 NED 5 Netherlands NED
## 4 AUS 1 Chile CHI
## 5 GRE 0 Colombia COL