What is a List?
You met with lists in the previous section. In simple wording, a list is a data type similar to a vector allowing for storing values of different types.
To create list in R, use the list()
function, passing all the values you want to store as the parameters. For example, we can store a single text string, number, and logical value in one 'container'.
1234# Creating a list test <- list("Text", 42, TRUE) # Output list value test
As you can see, the list output is much larger than the vector one.
Swipe to start coding
Create a list named info
with the information on the current chapter and course: 'R Introduction'
, 6
(section), 1
(chapter in the section), 41
(chapter overall). Output the value of this list, then.
Solution
Merci pour vos commentaires !
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
What is the difference between a list and a vector in R?
Can you explain how to access elements in a list?
Can I store other lists inside a list in R?
Awesome!
Completion rate improved to 2.27
What is a List?
Glissez pour afficher le menu
You met with lists in the previous section. In simple wording, a list is a data type similar to a vector allowing for storing values of different types.
To create list in R, use the list()
function, passing all the values you want to store as the parameters. For example, we can store a single text string, number, and logical value in one 'container'.
1234# Creating a list test <- list("Text", 42, TRUE) # Output list value test
As you can see, the list output is much larger than the vector one.
Swipe to start coding
Create a list named info
with the information on the current chapter and course: 'R Introduction'
, 6
(section), 1
(chapter in the section), 41
(chapter overall). Output the value of this list, then.
Solution
Merci pour vos commentaires !
Awesome!
Completion rate improved to 2.27single