Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
BA=(42)/(212)
BA
## [1] 0.1981132
Batting_Average = round(BA,digits = 3)
Batting_Average
## [1] 0.198
3 == 8
## [1] FALSE
3 < 5
## [1] TRUE
!TRUE
## [1] FALSE
!FALSE
## [1] TRUE
OBP=(156+65+3)/(565+65+3+7)
Batting_Average = round(OBP,digits = 3)
Batting_Average
## [1] 0.35
2 < 3 | 1 == 5
## [1] TRUE
2 > 3 | 2 == 3
## [1] FALSE
2 > 1 & 3 >= 3
## [1] TRUE
2 > 1 & 3 >= 4
## [1] FALSE
Total_Bases <- 16 + 5
Total_Bases
## [1] 21
pitches <- c(12, 15, 10, 20, 10)
pitches
## [1] 12 15 10 20 10
rep(3,4)
## [1] 3 3 3 3
2:5
## [1] 2 3 4 5
seq(1, 20, by=3)
## [1] 1 4 7 10 13 16 19
length(pitches)
## [1] 5
mean(pitches)
## [1] 13.4
median(pitches)
## [1] 12
min(pitches)
## [1] 10
var(pitches)
## [1] 17.8
sd(pitches)
## [1] 4.219005
pitches[1]
## [1] 12
data.frame(bonus = c(2, 3, 1),
active_roster = c("yes", "no", "yes"),
salary = c(1.5, 2.5, 1))
sample(1:10, size=5)
## [1] 8 4 5 6 10
x <- c("Yes","No","No","Yes","Yes")
table(x)
## x
## No Yes
## 2 3
summary(x)
## Length N.unique N.blank Min.nchar Max.nchar
## 5 2 0 2 3