Exercise 13: Compute the Range (Pg. 201)
df <- read.csv("./data/c5.13.csv", row.names=c("M","F"))
## Warning in read.table(file = file, header = header, sep = sep, quote
## = quote, : incomplete final line found by readTableHeader on './data/
## c5.13.csv'
df
sum(df)
## [1] 405
df2 <- df/sum(df)
df2
prob_M = sum(df2[1,])
print(prob_M)
## [1] 0.5530864
prob_F = sum(df2[2,])
print(prob_F)
## [1] 0.4469136
prob_Canada = sum(df2[,1])
prob_Canada
## [1] 0.5160494
prob_USA = sum(df2[,2])
prob_USA
## [1] 0.07901235
prob_Europe = sum(df2[,3])
prob_Europe
## [1] 0.06666667
prob_Asia = sum(df2[,4])
prob_Asia
## [1] 0.308642
prob_Others = sum(df2[,5])
prob_Others
## [1] 0.02962963
sum(df2[2,3:5])
## [1] 0.2148148