Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The c() function combines values into a vector or list in R.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The c() function combines character elements into a vector.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The elements must be separated by commas inside c().
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
list() instead of c() changes the data structure.Using
size() is not a valid function in R.✗ Incorrect
c() creates the vector and length() returns its length.
5fill in blank
hardFill 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'
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().✗ Incorrect
c() creates the vector, indexing with [2] gets the second fruit, and length() returns the count.