bike_sharing <- read.csv("bike_sharing_data.csv")
Question 4
Question 5
The total number of observations and variables for the bike sharing
data set is 17379 observations and 13 variables as displayed in the
first line in the results of the structure function.
str(bike_sharing)
## 'data.frame': 17379 obs. of 13 variables:
## $ datetime : chr "1/1/2011 0:00" "1/1/2011 1:00" "1/1/2011 2:00" "1/1/2011 3:00" ...
## $ season : int 1 1 1 1 1 1 1 1 1 1 ...
## $ holiday : int 0 0 0 0 0 0 0 0 0 0 ...
## $ workingday: int 0 0 0 0 0 0 0 0 0 0 ...
## $ weather : int 1 1 1 1 1 2 1 1 1 1 ...
## $ temp : num 9.84 9.02 9.02 9.84 9.84 ...
## $ atemp : num 14.4 13.6 13.6 14.4 14.4 ...
## $ humidity : chr "81" "80" "80" "75" ...
## $ windspeed : num 0 0 0 0 0 ...
## $ casual : int 3 8 5 3 0 0 2 1 1 8 ...
## $ registered: int 13 32 27 10 1 1 0 2 7 6 ...
## $ count : int 16 40 32 13 1 1 2 3 8 14 ...
## $ sources : chr "ad campaign" "www.yahoo.com" "www.google.fi" "AD campaign" ...
Question 6
Structure function displays the data types of each variable;
humidity is shown as a character.
str(bike_sharing)
## 'data.frame': 17379 obs. of 13 variables:
## $ datetime : chr "1/1/2011 0:00" "1/1/2011 1:00" "1/1/2011 2:00" "1/1/2011 3:00" ...
## $ season : int 1 1 1 1 1 1 1 1 1 1 ...
## $ holiday : int 0 0 0 0 0 0 0 0 0 0 ...
## $ workingday: int 0 0 0 0 0 0 0 0 0 0 ...
## $ weather : int 1 1 1 1 1 2 1 1 1 1 ...
## $ temp : num 9.84 9.02 9.02 9.84 9.84 ...
## $ atemp : num 14.4 13.6 13.6 14.4 14.4 ...
## $ humidity : chr "81" "80" "80" "75" ...
## $ windspeed : num 0 0 0 0 0 ...
## $ casual : int 3 8 5 3 0 0 2 1 1 8 ...
## $ registered: int 13 32 27 10 1 1 0 2 7 6 ...
## $ count : int 16 40 32 13 1 1 2 3 8 14 ...
## $ sources : chr "ad campaign" "www.yahoo.com" "www.google.fi" "AD campaign" ...
Question 7
The value of season in row 6251 is 4
bike_sharing$season[6251]
## [1] 4
Question 8
4232 observations have the season as winter. This was found by
creating a subset where season was equal to 4, and then viewing the
summary of that subset (called “Q8”).
Q8 <- subset(bike_sharing, season==4)
str(Q8)
## 'data.frame': 4232 obs. of 13 variables:
## $ datetime : chr "9/23/2011 0:00" "9/23/2011 1:00" "9/23/2011 2:00" "9/23/2011 3:00" ...
## $ season : int 4 4 4 4 4 4 4 4 4 4 ...
## $ holiday : int 0 0 0 0 0 0 0 0 0 0 ...
## $ workingday: int 1 1 1 1 1 1 1 1 1 1 ...
## $ weather : int 2 2 2 2 3 2 2 3 3 3 ...
## $ temp : num 25.4 24.6 24.6 24.6 24.6 ...
## $ atemp : num 27.3 25 25 25 25 ...
## $ humidity : chr "94" "100" "100" "100" ...
## $ windspeed : num 6 0 7 0 0 ...
## $ casual : int 5 2 1 1 1 1 4 6 10 7 ...
## $ registered: int 23 11 8 4 4 16 62 118 224 97 ...
## $ count : int 28 13 9 5 5 17 66 124 234 104 ...
## $ sources : chr "Ad Campaign" "facebook page" "ad campaign" "www.bing.com" ...
Question 10
46 observations have “High” wind thread condition or above during
winter or spring. NWS declares a wind thread of high when windspeed
>= 40.
Q10 <- subset(bike_sharing, (windspeed>=40) & (season %in% c("1","4")))
str(Q10)
## 'data.frame': 46 obs. of 13 variables:
## $ datetime : chr "2/14/2011 15:00" "2/14/2011 17:00" "2/14/2011 18:00" "2/14/2011 22:00" ...
## $ season : int 1 1 1 1 1 1 1 1 1 1 ...
## $ holiday : int 0 0 0 0 0 0 0 0 0 0 ...
## $ workingday: int 1 1 1 1 1 1 0 0 0 0 ...
## $ weather : int 1 1 1 1 1 1 1 1 1 1 ...
## $ temp : num 23 18.9 16.4 13.9 12.3 ...
## $ atemp : num 26.5 22.7 20.5 14.4 12.1 ...
## $ humidity : chr "21" "33" "40" "46" ...
## $ windspeed : num 44 41 41 44 52 ...
## $ casual : int 19 25 11 1 0 1 18 52 102 84 ...
## $ registered: int 71 218 194 44 5 2 37 103 94 87 ...
## $ count : int 90 243 205 45 5 3 55 155 196 171 ...
## $ sources : chr "www.google.co.uk" "ad campaign" "ad campaign" "www.google.co.uk" ...