Complete the code to check if 3 is in the vector.
3 [1] c(1, 2, 3, 4, 5)
The %in% operator checks if the left value is present in the right vector.
Complete the code to multiply two matrices A and B.
result <- A [1] BThe %*% operator performs matrix multiplication in R.
Fix the error in the code to check if 'apple' is in the fruits vector.
'apple' [1] fruits
The correct operator to check membership is %in%. Other options are invalid in R.
Fill both blanks to create a named vector with lengths of words longer than 3 characters.
lengths <- c([1] = [2] for word in words if nchar(word) > 3)
length(word) which returns 1 for strings.count(word) which is not a base R function.The names of the vector elements should be the words themselves, and the values should be their character counts using nchar().
Fill all three blanks to create a named vector of word lengths for words longer than 4 characters.
word_lengths <- c([1] = [2] for word in words if nchar(word) [3] 4)
length(word) instead of nchar(word).The vector names are the words, values are their lengths using nchar(), and the condition checks if length is greater than 4.