BikeData <- read.csv("./BikeData.csv")
message("Age of Cyclist 7: ",appendLF=FALSE)
## Age of Cyclist 7:
BikeData$age[7]
## [1] 45
message("Answer: ",appendLF=FALSE)
## Answer:
FirstTen <- head(BikeData,10)
nrow(FirstTen[FirstTen$cyc_freq == 'Daily',])
## [1] 3
Females <- BikeData[BikeData$gender == 'F',]
Lazy <- Females[Females$cyc_freq == 'Less than once a month',]
message("Average speed (miles/hour): ",appendLF=FALSE)
## Average speed (miles/hour):
Lazy$speed[1]
## [1] 8.1
typeof(BikeData$student)
## [1] "integer"
OBS. In fact is a binary variable that may assume 2 values, 1 for studant or 0 for other.
typeof(BikeData$cyc_freq)
## [1] "integer"
OBS. In fact is a categorical variable that may assume 4 diferent values that internaly in R is represented as an integer.
typeof(BikeData$distance)
## [1] "double"
OBS. Is a numerical value.
Answer: data frame
message("Numeber of Studants: ",appendLF=FALSE)
## Numeber of Studants:
Studants <- BikeData[BikeData$student == '1',]
nrow(Studants)
## [1] 14
table(Studants$cyc_freq)
##
## Daily Less than once a month Several times per month
## 8 0 0
## Several times per week
## 6
message("Average Distance: ",appendLF=FALSE)
## Average Distance:
mean(Studants$distance)
## [1] 6.257857
In this lab, we examined data on 14 student riders. Most of the student riders (a total of 8 out of 14 ) rode their bikes daily. On average, the students rode about 6.25 miles on each trip.