Exercise8

Exercise8 - times in minutes 17 16 20 24 22 15 21 15 17 22...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
R In Class Exercise 8 1. Try to guess the results of these R commands. Remember, the way to access entries in a vector is with [] . Suppose we assume > x = c(1,3,5,7,9) > y = c(2,3,5,7,11,13) 1. x+1 2. y*2 3. length(x) and length(y) 4. x + y 5. sum(x>5) and sum(x[x>5]) 6. sum(x>5 | x< 3) # read | as 'or', & and 'and' 7. y[3] 8. y[-3] 9. y[x] (What is NA?) 10. y[y>=7] 2. Let the data x be given by > x = c(1, 8, 2, 6, 3, 8, 5, 5, 5, 5) Use R to compute the following functions. Note, we use X 1 to denote the first element of x (which is 0) etc. 1. (X 1 + X 2 + …+ X 10 )/10 (use sum ) 2. Find log10(X i ) for each i. (Use the log function which by default is base e) 3. Find (X i – 4.4) = 2.875 for each i. (Do it all at once) 4. Find the difference between the largest and smallest values of x . (This is the range. You can use max and min or guess a built in command.)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
R 3. Suppose you track your commute times for two weeks (10 days) and you find the following
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: times in minutes 17 16 20 24 22 15 21 15 17 22 a) Enter this into R. Use the function max to find the longest commute time, the function mean to find the average and the function min to find the minimum. b) Oops, the 24 was a mistake. It should have been 18. How can you fix this? Do so, and then find the new average. c) How many times was your commute 20 minutes or more? d) What percent of your commutes are less than 17 minutes? How can you answer this with R? 4. Your cell phone bill varies from month to month. Suppose your year has the following monthly amounts 46 33 39 37 46 30 48 32 49 35 30 48 Enter this data into a variable called bill . a) Find the amount you spent this year on the cell phone. b) What is the smallest amount you spent in a month? What is the largest? c) How many months was the amount greater than $40? What percentage was this?...
View Full Document

This note was uploaded on 06/06/2011 for the course STAT 4360 taught by Professor Park during the Spring '11 term at UGA.

Page1 / 2

Exercise8 - times in minutes 17 16 20 24 22 15 21 15 17 22...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online