Complete the code to create a list with mixed types.
my_list <- list(1, "apple", [1], TRUE)
The list can hold different types like numbers, strings, and logical values. Here, 3.14 is a numeric value added to the list.
Complete the code to access the second element of the list.
second_element <- my_list[1]2
In R, double square brackets [[ ]] are used to extract elements from a list by position.
Fix the error in the code to add a new element to the list.
my_list[1] <- 42
To add a new element at position 5, use double square brackets with the index [[5]].
Fill both blanks to create a list with a numeric and a character element.
my_list <- list([1], [2])
The list holds a number 10 and a string "hello" as two different types.
Fill all three blanks to create a list and access its third element.
my_list <- list([1], [2], [3]) third_element <- my_list[[3]]
The list contains a string "apple", a number 3.14, and a number 42. The third element is accessed with [[3]].