0
0
R Programmingprogramming~10 mins

List to vector conversion 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 convert a list to a vector using unlist().

R Programming
my_list <- list(1, 2, 3)
my_vector <- [1](my_list)
Drag options to blanks, or click blank then click option'
Aunlist
Blist
Cc
Dvector
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() instead of unlist() which keeps the data as a list.
Using c() which concatenates but does not flatten nested lists properly.
2fill in blank
medium

Complete the code to convert a list of characters to a vector.

R Programming
char_list <- list('a', 'b', 'c')
char_vector <- [1](char_list)
Drag options to blanks, or click blank then click option'
Aunlist
Blist
Cas.vector
Dc
Attempts:
3 left
💡 Hint
Common Mistakes
Using as.vector() which does not flatten the list.
Using list() which keeps the data as a list.
3fill in blank
hard

Fix the error in converting a nested list to a vector.

R Programming
nested_list <- list(1, list(2, 3))
flat_vector <- [1](nested_list)
Drag options to blanks, or click blank then click option'
Avector
Bc
Cunlist
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using c() which does not flatten nested lists properly.
Using list() which keeps the nested structure.
4fill in blank
hard

Fill both blanks to create a numeric vector from a list and check its type.

R Programming
num_list <- list(4, 5, 6)
num_vector <- [1](num_list)
is_numeric <- is.[2](num_vector)
Drag options to blanks, or click blank then click option'
Aunlist
Bnumeric
Dvector
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() instead of unlist() to convert.
Using is.numeric as a variable instead of a function.
5fill in blank
hard

Fill all three blanks to convert a list to a vector, filter values greater than 2, and get the length.

R Programming
values <- list(1, 3, 5, 2)
vec <- [1](values)
filtered <- vec[vec [2] 2]
count <- length([3])
Drag options to blanks, or click blank then click option'
Aunlist
B>
Cfiltered
Dvec
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() instead of unlist() to convert.
Using wrong variable names in length().