Professional Documents
Culture Documents
D658
R tutorial
The most basic way to make a histogram is to use hist(). hist(S1) will
make a histogram of S1. You can make fancier by adding main and
xlab = “ ” to add new names and labels for the graph. col = “ ” will
change the color.
3. For a given data set, how do you compute the mean, median,
variance and standard deviation?
To calculate the mean, use mean(). It will give to the answer with
many decimals. Use the use trim = so short it. S1 = c(2,3,4)
mean(S1) will give us 3, but if it were a lot of numbers or a bunch
of prime numbers that didn’t go well together, you could use
mean(S1, trim = 0.5) to round it. Trim only reads from 0 – 0.5.
4. For a given data set, how do you find the critical five numbers
(minimum value, the first quartile, the second quartile (median), the
third quartile, maximum value) of the data set and how do you use a
box plot to present the five numbers?