0
0
R Programmingprogramming~10 mins

Why lists hold mixed types in R Programming - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a list with mixed types.

R Programming
my_list <- list(1, "apple", [1], TRUE)
Drag options to blanks, or click blank then click option'
A3.14
Blist()
Cc(1,2,3)
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using a vector like c(1,2,3) instead of a single value.
Using list() which creates an empty list inside the list.
2fill in blank
medium

Complete the code to access the second element of the list.

R Programming
second_element <- my_list[1]2
Drag options to blanks, or click blank then click option'
A%%
B[
C$
D[[
Attempts:
3 left
💡 Hint
Common Mistakes
Using single brackets which return a list, not the element.
Using $ which works only with named elements.
3fill in blank
hard

Fix the error in the code to add a new element to the list.

R Programming
my_list[1] <- 42
Drag options to blanks, or click blank then click option'
A[["5"]]
B[5]
C[[5]]
D$5
Attempts:
3 left
💡 Hint
Common Mistakes
Using single brackets which assign a sublist, not an element.
Using $ with a number which is invalid.
4fill in blank
hard

Fill both blanks to create a list with a numeric and a character element.

R Programming
my_list <- list([1], [2])
Drag options to blanks, or click blank then click option'
A10
B"hello"
CTRUE
Dc(1,2)
Attempts:
3 left
💡 Hint
Common Mistakes
Using a logical value TRUE instead of a number or string.
Using a vector c(1,2) which is not a single element.
5fill in blank
hard

Fill all three blanks to create a list and access its third element.

R Programming
my_list <- list([1], [2], [3])
third_element <- my_list[[3]]
Drag options to blanks, or click blank then click option'
A"apple"
B3.14
CTRUE
D42
Attempts:
3 left
💡 Hint
Common Mistakes
Using logical TRUE instead of a number for the third element.
Mixing up the order of elements.