Q4: Import the bike sharing dataset
bike <- read.csv("~/Desktop/Data dowloads/bike_sharing_data.csv")
Q5: Number of observations and variables
dim(bike)
## [1] 17379 13
Q6: Data type of humidity
class(bike$humidity)
## [1] "character"
Q7: Season in row 6251
bike[6251, "season"]
## [1] 4
Q8: Observations by season
dim(subset(bike,season==4))
## [1] 4232 13
Q9: Example of multiple conditions
head(subset(bike, season %in% c(1, 2) & windspeed >= 40))
## datetime season holiday workingday weather temp atemp humidity
## 1008 2/14/2011 15:00 1 0 1 1 22.96 26.515 21
## 1010 2/14/2011 17:00 1 0 1 1 18.86 22.725 33
## 1011 2/14/2011 18:00 1 0 1 1 16.40 20.455 40
## 1015 2/14/2011 22:00 1 0 1 1 13.94 14.395 46
## 1018 2/15/2011 1:00 1 0 1 1 12.30 12.120 42
## 1019 2/15/2011 2:00 1 0 1 1 11.48 11.365 41
## windspeed casual registered count sources
## 1008 43.9989 19 71 90 www.google.co.uk
## 1010 40.9973 25 218 243 ad campaign
## 1011 40.9973 11 194 205 ad campaign
## 1015 43.9989 1 44 45 www.google.co.uk
## 1018 51.9987 0 5 5 www.google.fi
## 1019 46.0022 1 2 3 www.google.fi
Q10: High wind during winter or spring
sum(bike$season %in% c(1, 4) & bike$windspeed >= 40)
## [1] 46