4

bike3 <- read.csv("~/Desktop/bike_sharing_data.csv")
head(bike3)
##        datetime season holiday workingday weather temp  atemp humidity
## 1 1/1/2011 0:00      1       0          0       1 9.84 14.395       81
## 2 1/1/2011 1:00      1       0          0       1 9.02 13.635       80
## 3 1/1/2011 2:00      1       0          0       1 9.02 13.635       80
## 4 1/1/2011 3:00      1       0          0       1 9.84 14.395       75
## 5 1/1/2011 4:00      1       0          0       1 9.84 14.395       75
## 6 1/1/2011 5:00      1       0          0       2 9.84 12.880       75
##   windspeed casual registered count       sources
## 1    0.0000      3         13    16   ad campaign
## 2    0.0000      8         32    40 www.yahoo.com
## 3    0.0000      5         27    32 www.google.fi
## 4    0.0000      3         10    13   AD campaign
## 5    0.0000      0          1     1       Twitter
## 6    6.0032      0          1     1  www.bing.com

6

summary(bike3)
##    datetime             season         holiday          workingday    
##  Length:17379       Min.   :1.000   Min.   :0.00000   Min.   :0.0000  
##  Class :character   1st Qu.:2.000   1st Qu.:0.00000   1st Qu.:0.0000  
##  Mode  :character   Median :3.000   Median :0.00000   Median :1.0000  
##                     Mean   :2.502   Mean   :0.02877   Mean   :0.6827  
##                     3rd Qu.:3.000   3rd Qu.:0.00000   3rd Qu.:1.0000  
##                     Max.   :4.000   Max.   :1.00000   Max.   :1.0000  
##     weather           temp           atemp         humidity        
##  Min.   :1.000   Min.   : 0.82   Min.   : 0.00   Length:17379      
##  1st Qu.:1.000   1st Qu.:13.94   1st Qu.:16.66   Class :character  
##  Median :1.000   Median :20.50   Median :24.24   Mode  :character  
##  Mean   :1.425   Mean   :20.38   Mean   :23.79                     
##  3rd Qu.:2.000   3rd Qu.:27.06   3rd Qu.:31.06                     
##  Max.   :4.000   Max.   :41.00   Max.   :50.00                     
##    windspeed          casual         registered        count    
##  Min.   : 0.000   Min.   :  0.00   Min.   :  0.0   Min.   :  1  
##  1st Qu.: 7.002   1st Qu.:  4.00   1st Qu.: 36.0   1st Qu.: 42  
##  Median :12.998   Median : 16.00   Median :116.0   Median :141  
##  Mean   :12.737   Mean   : 34.48   Mean   :152.5   Mean   :187  
##  3rd Qu.:16.998   3rd Qu.: 46.00   3rd Qu.:217.0   3rd Qu.:277  
##  Max.   :56.997   Max.   :367.00   Max.   :886.0   Max.   :977  
##    sources         
##  Length:17379      
##  Class :character  
##  Mode  :character  
##                    
##                    
## 

7

bike3[6251, "season"]
## [1] 4

8

table(bike3$season)
## 
##    1    2    3    4 
## 4242 4409 4496 4232
bike3$wind_cond <- cut(bike3$windspeed,
                       breaks = c(-Inf, 40.23, 55, Inf),
                       labels = c("Low", "High", "Extreme"),
                       right = FALSE)
high_wind <- subset(bike3, 
                    (season %in% c(1, 2)) & 
                    (wind_cond %in% c("High", "Extreme")))
nrow(high_wind)
## [1] 48