# Problem 1
my_feelings <- "I love stats!"
my_feelings
# Problem 2
fresh_15 <- c(72, 97, 74, 93, 68, 59, 64, 56, 70, 58, 50, 71, 67, 56, 70, 61, 53, 92, 57, 67,
58, 49, 68, 69, 87, 81, 60, 52, 70, 63, 56, 68, 68, 54, 80, 64, 57, 63, 54, 56,
54, 73, 77, 63, 51, 59, 65, 53, 62, 55, 74, 74, 64, 64, 57, 64, 60, 64, 66, 52,
71, 55, 65, 75, 42, 74, 94)
fresh_15
# Problem 2 part a
mean(fresh_15) # mean
median(fresh_15) # median
sd(fresh_15) # standard deviation
var(fresh_15) # variance
# Problem 2 part b
summary(fresh_15) # five number summary
boxplot(fresh_15, horizontal=TRUE) # box plot
# Problem 2 part c
hist(fresh_15) # histogram
library(plotrix) # recall: dot plot needs a special library loaded
dotplot.mtb(fresh_15) # dot plot
stem(fresh_15) # stem-leaf plot
The histogram has classes of width 5 whereas the dot plot shows the individual data points. So the histogram will show the data more grouped together and, therefore, has taller bars in the middle. Using the dot plot you can see exactly how the data is arranged and it is more accurate. The histogram shows more clearly the the data trend.
library(readxl) # load special library so that R can understand excel (spreadsheet) files
fresh_15_excel <- read_excel("06-Freshman15.xlsx") # save the excel spreadsheet to a descriptive name like "fresh_15_excel", or similar
str(fresh_15_excel) # str shows the "structure" of fresh_15_excel.
# str() also shows the first few rows of data
names(fresh_15_excel) # show names of columns
The first variable "SEX" keeps track of the gender of the individuals sampled. The second variable "WT SEPT" tells us the weight of the individuals in September of their freshman year and "WT APRIL" tells us the weight of the individuals in April of their freshman year.
Similarly, "BMI SEPT" and "BMI APRIL" tells us the BMI, or Body-Mass Index, of the individuals in September and in April of their freshman year.
# END OF LAB