Complete the code to calculate the mean of the vector, ignoring missing values.
mean(c(1, 2, NA, 4), [1] = TRUE)
The na.rm argument tells mean() to remove missing values before calculation.
Complete the code to remove missing values from the vector using a function.
clean_vector <- [1](c(3, NA, 5, NA, 7))
The na.omit() function removes all missing values from a vector or data frame.
Fix the error in the code to calculate the sum ignoring missing values.
sum_values <- sum(c(10, NA, 20), [1] = TRUE)
The correct argument to ignore missing values in sum() is na.rm.
Fill both blanks to create a named vector with lengths of words longer than 3 characters.
lengths <- {word: [1] for word in words if nchar(word) [2] 3}Use nchar(word) to get the length of each word and filter words with length greater than 3 using >.
Fill all three blanks to create a named vector of word lengths for words longer than 4 characters.
result <- list([1]: [2] for [3] in words if nchar([3]) > 4)
Use word as the key and nchar(word) as the value for each word longer than 4 characters.