0
0
R Programmingprogramming~10 mins

Why statistical tests validate hypotheses in R Programming - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to perform a t-test on the sample data.

R Programming
result <- t.test([1])
Drag options to blanks, or click blank then click option'
Asample
Bdata$values
Cvalues
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the whole data frame instead of the numeric vector.
2fill in blank
medium

Complete the code to check if the p-value is less than 0.05.

R Programming
if (result$p.value [1] 0.05) {
  print("Reject null hypothesis")
} else {
  print("Fail to reject null hypothesis")
}
Drag options to blanks, or click blank then click option'
A<
B>
C==
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of <, which reverses the logic.
3fill in blank
hard

Fix the error in the code to correctly extract the confidence interval lower bound.

R Programming
lower_bound <- result$conf.int[[1]]
Drag options to blanks, or click blank then click option'
A1
B2
C0
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as index, which is invalid in R.
4fill in blank
hard

Fill both blanks to create a subset of data where the group is 'A' and values are greater than 5.

R Programming
subset_data <- data[data$group [1] 'A' & data$values [2] 5, ]
Drag options to blanks, or click blank then click option'
A==
B>
C<
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of == for comparison.
Using < instead of > for filtering values.
5fill in blank
hard

Fill all three blanks to create a named vector of means for groups 'A' and 'B' where mean is greater than 10.

R Programming
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]])
Drag options to blanks, or click blank then click option'
A>
Bnames_filtered
Cfiltered_means
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for filtering.
Using wrong variable names for naming or printing.