0
0
R Programmingprogramming~10 mins

Nested lists in R Programming - Interactive Code Practice

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

Complete the code to create a nested list with two elements.

R Programming
nested_list <- list(1, [1])
Drag options to blanks, or click blank then click option'
Amatrix(2, 3)
B2:3
Clist(2, 3)
Dc(2, 3)
Attempts:
3 left
💡 Hint
Common Mistakes
Using c(2, 3) creates a vector, not a nested list.
Using 2:3 creates a sequence, not a nested list.
2fill in blank
medium

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

R Programming
nested_list <- list(1, list(2, 3))
second_element <- nested_list[[[1]]]
Drag options to blanks, or click blank then click option'
A1
B2
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using single brackets [ ] returns a sublist, not the element itself.
Using the wrong index number.
3fill in blank
hard

Fix the error in the code to access the number 3 inside the nested list.

R Programming
nested_list <- list(1, list(2, 3))
value <- nested_list[[2]][[[1]]]
Drag options to blanks, or click blank then click option'
A2
B1
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using [[1]] returns 2, not 3.
Using single brackets [ ] instead of double brackets.
4fill in blank
hard

Fill both blanks to create a nested list and access the number 4 inside it.

R Programming
nested_list <- list(1, list(3, [1]))
value <- nested_list[[2]][[[2]]]
Drag options to blanks, or click blank then click option'
A4
B1
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the positions of elements in the inner list.
Using wrong indices to access elements.
5fill in blank
hard

Fill all three blanks to create a nested list and access the number 6 inside it.

R Programming
nested_list <- list([1], list([2], 6))
value <- nested_list[[[3]]][[2]]
Drag options to blanks, or click blank then click option'
A5
B4
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong indices to access elements.
Confusing the order of elements in the lists.