###################################################################### # Cholesterol levels - percentiles # # Data from Ott and Longnecker (p. 93 of 7th edition) # ###################################################################### y <- c(133, 137, 148, 149, 152, 167, 174, 179, 189, 192, 201, 209, 210, 211, 218, 238, 245, 248, 253, 257) # While not needed, put the data into a data frame set1 <- data.frame(y = y) head(set1) type1 <- quantile(x = set1$y, probs = seq(from = 0.025, to = 0.975, by = 0.05), type = 1) type5 <- quantile(x = set1$y, probs = seq(from = 0.025, to = 0.975, by = 0.05), type = 5) type7 <- quantile(x = set1$y, probs = seq(from = 0.025, to = 0.975, by = 0.05)) #type = 7 is the default data.frame(y.sort = sort(set1$y), type5, type1, type7) #What happens between 0.025 and 0.075? quantile(x = set1$y, probs = seq(from = 0.025, to = 0.075, by = 0.01), type = 5) quantile(x = set1$y, probs = seq(from = 0.025, to = 0.075, by = 0.01), type = 1) quantile(x = set1$y, probs = seq(from = 0.025, to = 0.075, by = 0.01), type = 7) #What happens between 0.075 and 0.125? quantile(x = set1$y, probs = seq(from = 0.075, to = 0.125, by = 0.01), type = 5) quantile(x = set1$y, probs = seq(from = 0.075, to = 0.125, by = 0.01), type = 1) quantile(x = set1$y, probs = seq(from = 0.075, to = 0.125, by = 0.01), type = 7) quantile(x = set1$y, probs = 0.5, type = 5) median(set1$y) #