2.1

miles = c(65311, 65624, 65908, 66219, 66499, 66821, 67145, 67447)

x = diff(miles)

max(miles)

#[1] 67447

mean(miles)

#[1] 66371.75

2.2

mean(commutes)

# [1] 18.9

commutes[4] <- 18

mean(commutes)

# [1] 18.3

sum(commute>=20)

#[1] 4

sum(commute<17)/length(commute)*100

#[1] 30

2.3

Bill <- c(46 ,33 ,39 ,37 ,46 ,30 ,48 ,32 ,49 ,35 ,30 ,48)

sum(bill)

#[1] 473

min(bill)

#[1] 30

max(bill)

#[1] 49

sum(bill>40)

#[1] 5

sum(bill>40)/length(bill)*100

#[1] 41.66667

2.4 prices <- c(9000, 9500, 9400, 9400, 10000, 9500, 10300, 10200)

mean(prices)

#[1] 9662.5

mean(prices)<= 9500

#[1] FALSE

min(prices)

#[1] 9000

max(prices)

#[1] 10300

I would like to pay $9000, as it is the lowest price.

2.5 1. Guess: Each of the numbers contained within X will be increased by 1

  1. Guess: Each of the numbers contained within Y will be multiplied by 2

  2. Guess: The sum of the count of numbers within x and y

  3. Guess: The number in x will be added to the number in y in regards to their position in the vector

  4. Guess: Will print the count of items greater than 5 within x. Will print the sum of the numbers whose values are greater then 5

  5. Guess: Sum of those in X whose value is greater then 5 and sum of those in x whose value is greater then 3

  6. Guess: The number in Y whose position is 3 from the left

  7. Guess: The number in Y whose position is 3 from the right

  8. Guess: returns the numbers of Y within the positions of those numbers in X. NA mean Not Applicable, for those beyond the range of X.

  9. Guess: Returns all elements greater then 7 within Y

2.6

x = c(1, 8, 2, 6, 3, 8, 5, 5, 5, 5)

  1. sum(x)/10

[1] 4.8

# [1] 4.8
  1. log(x, base=10)
# [1] 0.0000000 0.9030900 0.3010300 0.7781513 0.4771213 0.9030900
# [7] 0.6989700 0.6989700 0.6989700 0.6989700
  1. (x - 4.4)/2.875
# [1] -1.1826087  1.2521739 -0.8347826  0.5565217 -0.4869565
# [6]  1.2521739  0.2086957  0.2086957  0.2086957  0.2086957
  1. diff(raneg(x))
# [1]  7