Complete the code to perform a t-test on the sample data.
result <- t.test([1])The t.test() function requires a numeric vector as input. Using data$values correctly passes the values column from the data frame.
Complete the code to check if the p-value is less than 0.05.
if (result$p.value [1] 0.05) { print("Reject null hypothesis") } else { print("Fail to reject null hypothesis") }
We reject the null hypothesis if the p-value is less than 0.05, indicating significant evidence against the null.
Fix the error in the code to correctly extract the confidence interval lower bound.
lower_bound <- result$conf.int[[1]]The confidence interval is a vector of length 2. The first element (index 1) is the lower bound.
Fill both blanks to create a subset of data where the group is 'A' and values are greater than 5.
subset_data <- data[data$group [1] 'A' & data$values [2] 5, ]
Use == to check equality for group 'A' and > to filter values greater than 5.
Fill all three blanks to create a named vector of means for groups 'A' and 'B' where mean is greater than 10.
means <- tapply(data$values, data$group, mean) filtered_means <- means[means [1] 10] names_filtered <- names(filtered_means) result <- setNames(filtered_means, [2]) print(result[[3]])
We filter means greater than 10 using >, then assign names using names_filtered, and print the filtered means.