Home
Register
Login
You cannot edit this comment!
×
Social Media Research
02 R Data Analysis
Question
list1<-list(1,"a", TRUE, c(2.2, 5.1))
Return the 4th element of list1.
Return the second value of the 4th element of list1.
Show Answer
Answer
list1[[4]]
list1[[4]][2]
Lists can be indexed in two ways:
[i]
returns a list of elements. i can be an integer or a vector
[i:j]
, just like when indexing a vector
[[i]]
returns a single element. i can only be a single value
Comments