Part 2.1
hist(precip, col="grey",xlab="Inches", ylab="Number of Cities",breaks=50)
The help page says that if you want an exact number of breaks you need a vector giving the breakpoints between histogram cells.
Part 2.2
hist(precip, col=“grey” xlab=“Inches”, ylab=“Number of Cities”,breaks=50)
generated the error message: Error: unexpected symbol in “hist(precip, col=”grey" xlab"
The error message means that the symbol x after “grey” doesn’t make sense.
part 2.3
1:6+1:2
## [1] 2 4 4 6 6 8
[1] 2 4 4 6 6 8
we add the vectors 1 2 3 4 5 6 to 1 2 1 2 1 2 by the recycling rule.
1:7 + 1:2
## Warning in 1:7 + 1:2: longer object length is not a multiple of shorter
## object length
## [1] 2 4 4 6 6 8 8
[1] 2 4 4 6 6 8 8
we add the vectors 1 2 3 4 5 6 7 to 1 2 1 2 1 2 1 by the recycling rule.
part 3
url<-"http://www.stat.berkeley.edu/users/cgk/teaching/assets/flow-occ-table.txt"
traffic<- read.csv(file=url,header=TRUE)
head(traffic)
## Occ1 Flow1 Occ2 Flow2 Occ3 Flow3
## 1 0.0100 14 0.0186 27 0.0137 17
## 2 0.0133 18 0.0250 39 0.0187 25
## 3 0.0088 12 0.0180 30 0.0095 11
## 4 0.0115 16 0.0203 33 0.0217 19
## 5 0.0069 8 0.0178 25 0.0123 13
## 6 0.0077 11 0.0151 24 0.0092 13
flow1<- traffic$Flow1
flow2<- traffic$Flow2
flow3<- traffic$Flow3
part 3.1
summary(flow1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 17.00 67.00 65.82 101.00 203.00
summary(flow2)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.0 35.0 84.0 74.8 107.0 174.0
summary(flow3)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.0 22.0 50.0 48.1 67.0 142.0
We use the mean of the flow to determine overall flow. The second lance has the highest mean flow and the third lane has the lowest mean flow.
part 3.2
hist(flow1,breaks=seq(from=0,to=225,by=25))
hist(flow2, breaks=seq(from=0,to=225,by=25))
hist(flow3, breaks=seq(from=0,to=225,by=25))