The Art of R Programming

(WallPaper) #1

$b
[1] 12



z$c <- "sailing" # add a c component


did c really get added?


z
$a
[1] "abc"



$b
[1] 12


$c
[1] "sailing"


Adding components can also be done via a vector index:


z[[4]] <- 28
z[5:7] <- c(FALSE,TRUE,TRUE)
z
$a
[1] "abc"



$b
[1] 12


$c
[1] "sailing"


[[4]]
[1] 28


[[5]]
[1] FALSE


[[6]]
[1] TRUE


[[7]]
[1] TRUE


You can delete a list component by setting it to NULL.


z$b <- NULL
z
$a
[1] "abc"



Lists 89
Free download pdf