$c
[1] "sailing"
[[3]]
[1] 28
[[4]]
[1] FALSE
[[5]]
[1] TRUE
[[6]]
[1] TRUE
Note that upon deletingz$b, the indices of the elements after it moved
up by 1. For instance, the formerz[[4]]becamez[[3]].
You can also concatenate lists.
> c(list("Joe", 55000, T),list(5))
[[1]]
[1] "Joe"
[[2]]
[1] 55000
[[3]]
[1] TRUE
[[4]]
[1] 5
4.2.3 Getting the Size of a List.........................................
Since a list is a vector, you can obtain the number of components in a list via
length().
> length(j)
[1] 3
4.2.4 Extended Example: Text Concordance............................
Web search and other types of textual data mining are of great interest
today. Let’s use this area for an example of R list code.
We’ll write a function calledfindwords()that will determine which words
are in a text file and compile a list of the locations of each word’s occur-
rences in the text. This would be useful for contextual analysis, for example.
90 Chapter 4