0
0
R Programmingprogramming~10 mins

Why R is essential for statistics 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 create a vector of numbers in R.

R Programming
numbers <- c([1])
Drag options to blanks, or click blank then click option'
A1, 2, 3, 4, 5
B1 2 3 4 5
C[1, 2, 3, 4, 5]
D(1, 2, 3, 4, 5)
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting commas between numbers
Using brackets or parentheses instead of commas
2fill in blank
medium

Complete the code to calculate the mean of a numeric vector in R.

R Programming
mean_value <- mean([1])
Drag options to blanks, or click blank then click option'
Adata
Bnumbers
Cvector
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the function name instead of the vector
Using an undefined variable
3fill in blank
hard

Fix the error in the code to create a data frame with columns 'age' and 'score'.

R Programming
df <- data.frame(age = c(25, 30, 22), score = [1](80, 90, 85))
Drag options to blanks, or click blank then click option'
Ac
Bvector
Cdata
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() instead of c()
Using undefined functions
4fill in blank
hard

Fill both blanks to create a subset of 'df' where age is greater than 23.

R Programming
subset_df <- df[df$[1] > [2], ]
Drag options to blanks, or click blank then click option'
Aage
B23
Cscore
D25
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name
Using a wrong comparison value
5fill in blank
hard

Fill all three blanks to calculate the correlation between 'age' and 'score' in 'df'.

R Programming
correlation <- cor(df$[1], df$[2], method = [3])
Drag options to blanks, or click blank then click option'
Aage
Bscore
C"pearson"
D"spearman"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping column names
Using method names without quotes
Using the wrong method