0
0
R Programmingprogramming~10 mins

List creation 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 list with numbers 1 to 5.

R Programming
my_list <- [1](1, 2, 3, 4, 5)
Drag options to blanks, or click blank then click option'
Aarray
Bc
Cvector
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() creates a list but not a simple vector of numbers.
Using vector() requires specifying the type and length.
2fill in blank
medium

Complete the code to create a list with elements 'apple', 'banana', and 'cherry'.

R Programming
fruits <- [1]("apple", "banana", "cherry")
Drag options to blanks, or click blank then click option'
Alist
Barray
Cvector
Dc
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() creates a list but the question expects a vector.
Using vector() requires specifying the type and length.
3fill in blank
hard

Fix the error in the code to create a list with numbers 1, 2, and 3.

R Programming
numbers <- [1](1, 2, 3)
Drag options to blanks, or click blank then click option'
Ac
Blist
Cvector
Darray
Attempts:
3 left
💡 Hint
Common Mistakes
Missing commas between elements causes syntax errors.
Using list() is valid but the question asks to fix the error in this code.
4fill in blank
hard

Fill both blanks to create a list of numbers from 1 to 5 and check its length.

R Programming
my_list <- [1](1, 2, 3, 4, 5)
length_of_list <- [2](my_list)
Drag options to blanks, or click blank then click option'
Ac
Blength
Clist
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() instead of c() changes the data structure.
Using size() is not a valid function in R.
5fill in blank
hard

Fill all three blanks to create a list of fruits, access the second fruit, and get the total count.

R Programming
fruits <- [1]("apple", "banana", "cherry")
second_fruit <- fruits[[2]]
total_fruits <- [3](fruits)
Drag options to blanks, or click blank then click option'
Ac
B2
Clength
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of 2 to access the second fruit.
Using list() instead of c() changes the data type.
Using size() instead of length().