Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a numeric variable with value 10.
R Programming
num <- [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number, which makes it a string.
Using TRUE which is logical, not numeric.
✗ Incorrect
The number 10 is assigned directly as a numeric value without quotes.
2fill in blank
mediumComplete the code to check if variable x is numeric.
R Programming
is.numeric([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the variable name as a string.
Passing a literal number instead of the variable.
✗ Incorrect
Use the variable name without quotes to check its type.
3fill in blank
hardFix the error in the code to convert a string to numeric.
R Programming
num <- as.numeric([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a numeric value directly to as.numeric().
Passing a logical value instead of a string.
✗ Incorrect
Use a string "10" to convert it to numeric with as.numeric().
4fill in blank
hardFill both blanks to create a numeric vector and check its type.
R Programming
vec <- c([1], [2]) is.numeric(vec)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted numbers which create character vectors.
Mixing numeric and character values in the vector.
✗ Incorrect
Use numeric values 5 and 10 without quotes to create a numeric vector.
5fill in blank
hardFill all three blanks to create a numeric vector, convert a string to numeric, and check types.
R Programming
vec <- c([1], [2]) num <- as.numeric([3]) is.numeric(vec) && is.numeric(num)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted numbers in the vector.
Passing numeric values directly to as.numeric() unnecessarily.
✗ Incorrect
Use numeric values 3 and 3 for the vector, convert string "7" to numeric.