Question 4

Checking extraction methods

bike1 <- read.table("~/Downloads/bike_sharing_data.csv", sep=",", header=TRUE)


bike4 <- read.delim("~/Downloads/bike_sharing_data.txt")


bike3 <- read.csv("~/Downloads/bike_sharing_data.csv")


bike2 <- read.table("~/Downloads/bike_sharing_data.txt", sep="\t", header=TRUE)

Question 6

Check the data type of the humidity variable

humidity_type <- class(bike1$humidity)
print(humidity_type)
## [1] "character"
str(humidity_type)
##  chr "character"

Question 7

Retrieve the value of ‘season’ in row 6251

season_value <- bike1$season[6251]
print(season_value)
## [1] 4

Question 8

Create a contingency table for the ‘season’ variable and print the table

season_counts <- table(bike1$season)
print(season_counts)
## 
##    1    2    3    4 
## 4242 4409 4496 4232

Get the count for winter (#1)

winter_count <- season_counts["1"]
print(winter_count)
##    1 
## 4242

Question 10

Filter for observations with high wind speed (40 mph and above) during winter (1) or spring (2)

high_wind <- bike1[(bike1$windspeed >= 40) & 
  (bike1$season == 1 | bike1$season == 2), ]

Count the number of observations and print

num_high_wind <- nrow(high_wind)
print(num_high_wind)
## [1] 48