Ch20 Vectors

1 Introduction

2 Vector basics

3 Important types of atomic vector

4 Using atomic vectors

##  [1] 18 19 12 11 17 14 13 20 16 15
##  [1]  2  4  4  6  6  8  8 10 10 12
## Warning in 1:10 + 1:3: longer object length is not a multiple of shorter object
## length
##  [1]  2  4  6  5  7  9  8 10 12 11
##     a b
## 1   1 1
## 2   2 2
## 3   3 1
## 4   4 2
## 5   5 1
## 6   6 2
## 7   7 1
## 8   8 2
## 9   9 1
## 10 10 2
##  [1]  7  3  1  2  4  8  6  5  9 10
## [1] 4 6
## [1]  7  8  6  9 10

5 Recursive vectors (lists)

## $a
## [1] 1 2 3
## 
## $b
## [1] "a string"
## 
## $c
## [1] 3.141593
## 
## $d
## $d[[1]]
## [1] -1
## 
## $d[[2]]
## [1] -5
## $a
## [1] 1 2 3
## 
## $b
## [1] "a string"
## [[1]]
## [1] -1
## 
## [[2]]
## [1] -5
## [[1]]
## [1] -5
## [1] -5

6 Attributes

7 Augmented vectors

Ch21 Iteration

1 Introduction

2 For loops

## [1] 11
## [1] 12
## [1] 13
## [1] 14
## [1] 21
## [1] 22
## [1] 23
## [1] 24
## [1] 25
## [1] 21
## [1] 22
## [1] 23
## [1] 24
## [1] 25
## [1] 21 22 23 24 25
## [1] "a"
## [1] "x"
## [1] "a" "x"

3 The map functions

## [1] 21
## [1] 22
## [1] 23
## [1] 24
## [1] 25
## [1] 21 22 23 24 25
## [1] 11 12 13 14 15
## [[1]]
## [1] 21
## 
## [[2]]
## [1] 22
## 
## [[3]]
## [1] 23
## 
## [[4]]
## [1] 24
## 
## [[5]]
## [1] 25
## [1] 21 22 23 24 25
## [1] 21
## [1] 21 22 23 24 25

4 Dealing failure

5 Mapping over multiple arguments