How does a list differ from a vector?
A list can contain values of different data types
Create a list, called "list1", containing three values- the first one the vector c(1, 3, 4), the second one the character vector "test", and the third one the number 4.
list1 = list(c(1, 3, 4), "test", 4)
Extract the third value from the list list1
list1[[3]]
Create a list, called "list2", containing three values- the first one the vector c(1, 3, 4), the second one the character vector "test", and the third one the number 4, but this time give each of the items names- "a", "b", "c".
list2 = list(c(1, 3, 4), "test", 4)
Extract the value named "c" from list2 using its name
list2$c
The "iris" data.frame comes built into R and contains measurements on 150 flowers of three different species.
Load the iris dataset into your workspace
data("iris")
View the iris dataset like a spreadsheet
View(iris)
How many columns does the iris dataset have?
5
Extract the "Species" column from the Iris dataset
iris$Species
Extract the third row from the Iris dataset
iris[3, ]
Extract the first 5 rows from the Iris dataset
iris[1:5, ]