0
0
R Programmingprogramming~10 mins

Chi-squared test in R Programming - Interactive Code Practice

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

Complete the code to perform a chi-squared test on the table 'data_table'.

R Programming
result <- chisq.test([1])
Drag options to blanks, or click blank then click option'
Amatrix()
Bdata.frame
Cdata_table
Dtable()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a function call like matrix() instead of the table variable.
Using data.frame which is not a contingency table.
2fill in blank
medium

Complete the code to extract the p-value from the chi-squared test result stored in 'result'.

R Programming
p_value <- result$[1]
Drag options to blanks, or click blank then click option'
Astatistic
Bobserved
Cparameter
Dp.value
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'statistic' which gives the test statistic, not the p-value.
Using 'parameter' or 'observed' which are different parts of the result.
3fill in blank
hard

Fix the error in the code to correctly create a contingency table from vectors 'group' and 'outcome'.

R Programming
table_data <- [1](group, outcome)
Drag options to blanks, or click blank then click option'
Atable
Bmatrix
Ccbind
Ddata.frame
Attempts:
3 left
💡 Hint
Common Mistakes
Using cbind which just binds columns without counting.
Using data.frame or matrix which do not create frequency tables.
4fill in blank
hard

Fill both blanks to perform a chi-squared test with continuity correction disabled on 'table_data'.

R Programming
result <- chisq.test([1], [2]FALSE)
Drag options to blanks, or click blank then click option'
Atable_data
Bcorrect =
Ccorrect=
Ddata_table
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'correct = ' with spaces around the equals sign.
Passing wrong variable names like 'data_table'.
5fill in blank
hard

Fill all three blanks to create a table from 'gender' and 'smoking' vectors, perform a chi-squared test, and extract the test statistic.

R Programming
tab <- [1](gender, smoking)
result <- chisq.test([2])
st <- result$[3]
Drag options to blanks, or click blank then click option'
Atable
Btab
Cstatistic
Ddata.frame
Attempts:
3 left
💡 Hint
Common Mistakes
Using data.frame instead of table.
Passing wrong variable names or extracting wrong elements.