Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign a missing value in R.
R Programming
x <- [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using NULL instead of NA for missing data.
✗ Incorrect
In R, NA represents a missing value, while NULL means no value or empty.
2fill in blank
mediumComplete the code to check if a value is NA.
R Programming
is.na([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking
is.na(NA) directly instead of a variable.✗ Incorrect
The function is.na() checks if the value x is missing (NA).
3fill in blank
hardFix the error in the code to remove NULL values from a vector.
R Programming
clean_vec <- vec[!is.null([1])] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
is.null() to filter vector elements, which does not work element-wise.✗ Incorrect
The function is.null() does not work element-wise on vectors. Use vec inside the brackets to filter.
4fill in blank
hardFill both blanks to create a vector without NA values.
R Programming
clean_vec <- vec[]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
is.null instead of is.na to check missing values.✗ Incorrect
Use is.na() to check for missing values and vec as the vector to filter.
5fill in blank
hardFill both blanks to replace NA values with zero in a vector.
R Programming
vec[[1](vec)] <- [2] vec
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
is.null instead of is.na to find missing values.✗ Incorrect
Use is.na() to find missing values and replace them with 0.