#Import a Flat File

Bike <- read.csv("bike_sharing_data (1).csv")

Bikes <- read.delim("bike_sharing_data.txt")

Question 3

?read.table

Question 4

Bike2 <- read.table("bike_sharing_data.txt", sep="\t", header=TRUE)
bike4 <- read.delim("bike_sharing_data.txt")
bike1 <- read.table("bike_sharing_data (1).csv", sep=",", header=TRUE)
bike3 <- read.csv("bike_sharing_data (1).csv")

Question 5

str(Bike)
## '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

class(bike1$humidity)
## [1] "character"

Question 7

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

Question 8

table(bike1$season)[4]
##    4 
## 4232

Question 9

bike1[bike1$season == "winter" & bike1$wind_speed == "high", ]
##  [1] datetime   season     holiday    workingday weather    temp      
##  [7] atemp      humidity   windspeed  casual     registered count     
## [13] sources   
## <0 rows> (or 0-length row.names)

Question 10

sum(
  bike1$season %in% c(4, 1) & 
    bike1$windspeed >= 40
)
## [1] 46