Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 Below are the data and summary statistics again: S: 2, 6, 4, 6, 4, 5, 5, 6, 5,

ID: 3073256 • Letter: 1

Question

1 Below are the data and summary statistics again: S: 2, 6, 4, 6, 4, 5, 5, 6, 5, 6, 7, 5, 4, 8 ns = 14 Y¯ s = 5.2 Ss = 1.48

NS: 1, 5, 3, 5, 3, 4, 4, 5, 4, 5, 6, 4, 3, 7, 4 nns = 15 Y¯ ns = 4.2 Sns = 1.42

Here is a line of R code which creates a vector of the wrinkle scores with the first 14 items for Smokers and the next 15 for Non-Smokers: Y <- c(2, 6, 4, 6, 4, 5, 5, 6, 5, 6, 7, 5, 4, 8, 1, 5, 3, 5, 3, 4, 4, 5, 4, 5, 6, 4, 3, 7, 4)

Provide lines of R code to do the following:

A. Create a vector called group which consists of 14 1’s (for smokers) followed by 15 0’s (for nonsmokers), to go along with Y . (Do not type out a vector of 29 values; use a short-cut method.)

B. Compute the mean wrinkle score for smokers, and the mean wrinkle score for nonsmokers.

Explanation / Answer

a)

smoker <- rep (1,14)
nonSmoker <- rep(0,15)
Vector <- c(smoker,nonSmoker)
> Vector
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

b)

Y <- c(2, 6, 4, 6, 4, 5, 5, 6, 5, 6, 7, 5, 4, 8, 1, 5, 3, 5, 3, 4, 4, 5, 4, 5, 6, 4, 3, 7, 4)

mean (Y[c(1:14)])
[1] 5.214286

mean (Y[c(15:29)])
[1] 4.2