high_temps<-c(90, 87, 89, 90, 88, 86, 91, 89, 88, 85, 83, 88, 80, 83, 87, 89, 89, 91, 93, 92, 92, 92, 76, 79, 78, 75, 79, 85, 83, 88, 86) # # the functon mean() calculates the mean (i.e. average) # of the vector values # ave <- mean(high_temps) ave # # the median() function calculates the central value # of the temperatures if the are ordered (sorted) # middle <- median(high_temps) middle # # the sd() function calculates the standard deviation # it coincides with what Excel calls stdev.s (the sample version) # stdev <- sd(high_temps) stdev # # the min() function determines the lowest value # least <- min(high_temps) least # # the max() function determines the highest value # most <- max(high_temps) most # # the quantile() function can be used to obtain # the first quartile # note the R function has an "n" as opposed to an "r" # first_quartile <- quantile(high_temps, 0.25) first_quartile # # the quantile() function can be used to obtain # the third quartile # third_quartile <- quantile(high_temps, 0.75) third_quartile # # the summary() function is a fast way to obtain # many of the above statistics # high_temps_summary <- summary(high_temps) high_temps_summary # # we can use the sort() function to put the temperatures # in order from lowest to highest # sorted_high_temps <- sort(high_temps) sorted_high_temps # # then the second smallest temperature has an # index of 2 # second_smallest <- sorted_high_temps[2] second_smallest # # length determines the size of the vector which # in this case is the number of temperatures (or days) # sample_size = length(high_temps) sample_size # # the second largest has an index of the length minus one # second_largest <- sorted_high_temps[sample_size -1] second_largest # # use hist() to make a fast histogram of the data # hist(high_temps) # # use boxplot() to make a fast"box and whiskers" plot # boxplot(high_temps) # # boxplot.stats tells us # stats: min | 1st-quart | median | 3rd-quart | max # n: sample size # conf: a range based on the inter-quartile range and sample size # Out: list any outliers -- non here # boxplot.stats(high_temps)