class: left, top, inverse background-image: url(https://images.unsplash.com/reserve/uZYSV4nuQeyq64azfVIn_15130980706_64134efc6e_o.jpg?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1047&q=80) background-size: cover # .large[Data types] ### An exploration <br>with {flipbookr}<br>and {xaringan} <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> #### .right[Gina Reynolds<br>Photo Credit: Amador Loureiro] --- count: false .panel1-basic-auto[ ```r *1 + 1 ``` ] .panel2-basic-auto[ ``` [1] 2 ``` ] --- count: false .panel1-basic-auto[ ```r 1 + 1 *5 * 8 ``` ] .panel2-basic-auto[ ``` [1] 2 ``` ``` [1] 40 ``` ] --- count: false .panel1-basic-auto[ ```r 1 + 1 5 * 8 *(4 + 2)^2 ``` ] .panel2-basic-auto[ ``` [1] 2 ``` ``` [1] 40 ``` ``` [1] 36 ``` ] --- count: false .panel1-basic-auto[ ```r 1 + 1 5 * 8 (4 + 2)^2 *3 / (3 + 6) ``` ] .panel2-basic-auto[ ``` [1] 2 ``` ``` [1] 40 ``` ``` [1] 36 ``` ``` [1] 0.3333333 ``` ] <style> .panel1-basic-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-basic-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-basic-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-vec-auto[ ```r *3:10 ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 *1:6 * 2 ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 *c(1, 2, 6, 10) ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) *1:4 + 0:3 ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 *TRUE ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 TRUE *c(T, T, F, F) ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ``` [1] TRUE TRUE FALSE FALSE ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 TRUE c(T, T, F, F) *"hello world" ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ``` [1] TRUE TRUE FALSE FALSE ``` ``` [1] "hello world" ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 TRUE c(T, T, F, F) "hello world" *c("hello", "hi", "bye", "bye-bye") ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ``` [1] TRUE TRUE FALSE FALSE ``` ``` [1] "hello world" ``` ``` [1] "hello" "hi" "bye" "bye-bye" ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 TRUE c(T, T, F, F) "hello world" c("hello", "hi", "bye", "bye-bye") *NULL ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ``` [1] TRUE TRUE FALSE FALSE ``` ``` [1] "hello world" ``` ``` [1] "hello" "hi" "bye" "bye-bye" ``` ``` NULL ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 TRUE c(T, T, F, F) "hello world" c("hello", "hi", "bye", "bye-bye") NULL *factor(c("hello", "hi", "bye", "bye")) ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ``` [1] TRUE TRUE FALSE FALSE ``` ``` [1] "hello world" ``` ``` [1] "hello" "hi" "bye" "bye-bye" ``` ``` NULL ``` ``` [1] hello hi bye bye Levels: bye hello hi ``` ] --- count: false .panel1-vec-auto[ ```r 3:10 1:6 * 2 c(1, 2, 6, 10) 1:4 + 0:3 TRUE c(T, T, F, F) "hello world" c("hello", "hi", "bye", "bye-bye") NULL factor(c("hello", "hi", "bye", "bye")) *factor(c("hello", "hi", * "bye", "bye"), * levels = c("hi", "hello", * "bye", "bye-bye")) ``` ] .panel2-vec-auto[ ``` [1] 3 4 5 6 7 8 9 10 ``` ``` [1] 2 4 6 8 10 12 ``` ``` [1] 1 2 6 10 ``` ``` [1] 1 3 5 7 ``` ``` [1] TRUE ``` ``` [1] TRUE TRUE FALSE FALSE ``` ``` [1] "hello world" ``` ``` [1] "hello" "hi" "bye" "bye-bye" ``` ``` NULL ``` ``` [1] hello hi bye bye Levels: bye hello hi ``` ``` [1] hello hi bye bye Levels: hi hello bye bye-bye ``` ] <style> .panel1-vec-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-vec-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-vec-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-str-auto[ ```r *str(3) ``` ] .panel2-str-auto[ ``` num 3 ``` ] --- count: false .panel1-str-auto[ ```r str(3) *str("hello") ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") *str(1.1) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) *str(1:8) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) *str(2L) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) *str(c(2, 5, 8)) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) str(c(2, 5, 8)) *str(c(2L, 5L, 8L)) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ``` int [1:3] 2 5 8 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) str(c(2, 5, 8)) str(c(2L, 5L, 8L)) *str(c(1,3)) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ``` int [1:3] 2 5 8 ``` ``` num [1:2] 1 3 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) str(c(2, 5, 8)) str(c(2L, 5L, 8L)) str(c(1,3)) *str(factor(c("hello", "bye"))) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ``` int [1:3] 2 5 8 ``` ``` num [1:2] 1 3 ``` ``` Factor w/ 2 levels "bye","hello": 2 1 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) str(c(2, 5, 8)) str(c(2L, 5L, 8L)) str(c(1,3)) str(factor(c("hello", "bye"))) *str(factor(c("hello", "bye"), * levels = c("hi", "hello", * "bye"))) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ``` int [1:3] 2 5 8 ``` ``` num [1:2] 1 3 ``` ``` Factor w/ 2 levels "bye","hello": 2 1 ``` ``` Factor w/ 3 levels "hi","hello","bye": 2 3 ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) str(c(2, 5, 8)) str(c(2L, 5L, 8L)) str(c(1,3)) str(factor(c("hello", "bye"))) str(factor(c("hello", "bye"), levels = c("hi", "hello", "bye"))) *str(Sys.time()) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ``` int [1:3] 2 5 8 ``` ``` num [1:2] 1 3 ``` ``` Factor w/ 2 levels "bye","hello": 2 1 ``` ``` Factor w/ 3 levels "hi","hello","bye": 2 3 ``` ``` POSIXct[1:1], format: "2020-09-01 22:02:18" ``` ] --- count: false .panel1-str-auto[ ```r str(3) str("hello") str(1.1) str(1:8) str(2L) str(c(2, 5, 8)) str(c(2L, 5L, 8L)) str(c(1,3)) str(factor(c("hello", "bye"))) str(factor(c("hello", "bye"), levels = c("hi", "hello", "bye"))) str(Sys.time()) *str(Sys.Date()) ``` ] .panel2-str-auto[ ``` num 3 ``` ``` chr "hello" ``` ``` num 1.1 ``` ``` int [1:8] 1 2 3 4 5 6 7 8 ``` ``` int 2 ``` ``` num [1:3] 2 5 8 ``` ``` int [1:3] 2 5 8 ``` ``` num [1:2] 1 3 ``` ``` Factor w/ 2 levels "bye","hello": 2 1 ``` ``` Factor w/ 3 levels "hi","hello","bye": 2 3 ``` ``` POSIXct[1:1], format: "2020-09-01 22:02:18" ``` ``` Date[1:1], format: "2020-09-01" ``` ] <style> .panel1-str-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-str-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-str-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-mat-auto[ ```r *matrix(1:10, nrow = 5) ``` ] .panel2-mat-auto[ ``` [,1] [,2] [1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10 ``` ] --- count: false .panel1-mat-auto[ ```r matrix(1:10, nrow = 5) *matrix(1:10, ncol = 3) ``` ] .panel2-mat-auto[ ``` [,1] [,2] [1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10 ``` ``` [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 1 [4,] 4 8 2 ``` ] --- count: false .panel1-mat-auto[ ```r matrix(1:10, nrow = 5) matrix(1:10, ncol = 3) *matrix(c(1,2,3,4), * nrow = 2) * 2 ``` ] .panel2-mat-auto[ ``` [,1] [,2] [1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10 ``` ``` [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 1 [4,] 4 8 2 ``` ``` [,1] [,2] [1,] 2 6 [2,] 4 8 ``` ] --- count: false .panel1-mat-auto[ ```r matrix(1:10, nrow = 5) matrix(1:10, ncol = 3) matrix(c(1,2,3,4), nrow = 2) * 2 *(matrix(c(1,2,3,4), * nrow = 2) * * matrix(c(1,2,3,4), * nrow = 2) ) ``` ] .panel2-mat-auto[ ``` [,1] [,2] [1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10 ``` ``` [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 1 [4,] 4 8 2 ``` ``` [,1] [,2] [1,] 2 6 [2,] 4 8 ``` ``` [,1] [,2] [1,] 1 9 [2,] 4 16 ``` ] --- count: false .panel1-mat-auto[ ```r matrix(1:10, nrow = 5) matrix(1:10, ncol = 3) matrix(c(1,2,3,4), nrow = 2) * 2 (matrix(c(1,2,3,4), nrow = 2) * matrix(c(1,2,3,4), nrow = 2) ) *(matrix(c(1,2,3,4), * nrow = 2) %*% * matrix(c(1,2,3,4), * nrow = 2) ) ``` ] .panel2-mat-auto[ ``` [,1] [,2] [1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10 ``` ``` [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 1 [4,] 4 8 2 ``` ``` [,1] [,2] [1,] 2 6 [2,] 4 8 ``` ``` [,1] [,2] [1,] 1 9 [2,] 4 16 ``` ``` [,1] [,2] [1,] 7 15 [2,] 10 22 ``` ] <style> .panel1-mat-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-mat-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-mat-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # constructing data in r --- count: false .panel1-dat-auto[ ```r *data.frame( * id = 1:6, * greet = c("hi", "bye", * "hello", "chao", * "adios", "tchuss"), * nums = c(2.3, 4.1, 3.5, * 3.2, 5.6, 8.9)) ``` ] .panel2-dat-auto[ ``` id greet nums 1 1 hi 2.3 2 2 bye 4.1 3 3 hello 3.5 4 4 chao 3.2 5 5 adios 5.6 6 6 tchuss 8.9 ``` ] --- count: false .panel1-dat-auto[ ```r data.frame( id = 1:6, greet = c("hi", "bye", "hello", "chao", "adios", "tchuss"), nums = c(2.3, 4.1, 3.5, 3.2, 5.6, 8.9)) *library(tibble) # also a part of the tidyverse ``` ] .panel2-dat-auto[ ``` id greet nums 1 1 hi 2.3 2 2 bye 4.1 3 3 hello 3.5 4 4 chao 3.2 5 5 adios 5.6 6 6 tchuss 8.9 ``` ] --- count: false .panel1-dat-auto[ ```r data.frame( id = 1:6, greet = c("hi", "bye", "hello", "chao", "adios", "tchuss"), nums = c(2.3, 4.1, 3.5, 3.2, 5.6, 8.9)) library(tibble) # also a part of the tidyverse # tribble helps build small data sets *tribble( * ~"id", ~"greet", ~"nums", # column heads * 1, "hi", 2.3, * 2, "bye", 3.5, * 3, "adios", 4.2 * ) ``` ] .panel2-dat-auto[ ``` id greet nums 1 1 hi 2.3 2 2 bye 4.1 3 3 hello 3.5 4 4 chao 3.2 5 5 adios 5.6 6 6 tchuss 8.9 ``` ``` # A tibble: 3 x 3 id greet nums <dbl> <chr> <dbl> 1 1 hi 2.3 2 2 bye 3.5 3 3 adios 4.2 ``` ] <style> .panel1-dat-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-dat-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-dat-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-fun-auto[ ```r *mean(1:5) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) *mean(1:100^2) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) mean(1:100^2) *sd(1:10) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ``` [1] 3.02765 ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) mean(1:100^2) sd(1:10) *mean(c(1, 4, 6, 7)) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ``` [1] 3.02765 ``` ``` [1] 4.5 ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) mean(1:100^2) sd(1:10) mean(c(1, 4, 6, 7)) *mean(c(1, 4, 6, 7, NA)) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ``` [1] 3.02765 ``` ``` [1] 4.5 ``` ``` [1] NA ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) mean(1:100^2) sd(1:10) mean(c(1, 4, 6, 7)) mean(c(1, 4, 6, 7, NA)) *mean(c(1, 4, 6, 7, NA), na.rm = T) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ``` [1] 3.02765 ``` ``` [1] 4.5 ``` ``` [1] NA ``` ``` [1] 4.5 ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) mean(1:100^2) sd(1:10) mean(c(1, 4, 6, 7)) mean(c(1, 4, 6, 7, NA)) mean(c(1, 4, 6, 7, NA), na.rm = T) *sd(c(1:10, NA)) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ``` [1] 3.02765 ``` ``` [1] 4.5 ``` ``` [1] NA ``` ``` [1] 4.5 ``` ``` [1] NA ``` ] --- count: false .panel1-fun-auto[ ```r mean(1:5) mean(1:100^2) sd(1:10) mean(c(1, 4, 6, 7)) mean(c(1, 4, 6, 7, NA)) mean(c(1, 4, 6, 7, NA), na.rm = T) sd(c(1:10, NA)) *sd(c(1:10, NA), na.rm = T) ``` ] .panel2-fun-auto[ ``` [1] 3 ``` ``` [1] 5000.5 ``` ``` [1] 3.02765 ``` ``` [1] 4.5 ``` ``` [1] NA ``` ``` [1] 4.5 ``` ``` [1] NA ``` ``` [1] 3.02765 ``` ] <style> .panel1-fun-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-fun-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-fun-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-assign-auto[ ```r *1:10 ``` ] .panel2-assign-auto[ ``` [1] 1 2 3 4 5 6 7 8 9 10 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> * x ``` ] .panel2-assign-auto[ ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x *x * 5 ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 *x^2 ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 *rep(3, 10) ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ``` [1] 3 3 3 3 3 3 3 3 3 3 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> * y ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y *x + y ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ``` [1] 4 5 6 7 8 9 10 11 12 13 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> * z ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z *5 ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ``` [1] 5 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z 5 -> * x ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z 5 -> x *4 ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ``` [1] 4 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z 5 -> x 4 -> * y ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z 5 -> x 4 -> y *x + y ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ``` [1] 9 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z 5 -> x 4 -> y x + y -> * z_1 ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ] --- count: false .panel1-assign-auto[ ```r 1:10 -> x x * 5 x^2 rep(3, 10) -> y x + y -> z 5 -> x 4 -> y x + y -> z_1 *z; z_1 # print both objects z and z_1 ``` ] .panel2-assign-auto[ ``` [1] 5 10 15 20 25 30 35 40 45 50 ``` ``` [1] 1 4 9 16 25 36 49 64 81 100 ``` ``` [1] 4 5 6 7 8 9 10 11 12 13 ``` ``` [1] 9 ``` ] <style> .panel1-assign-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-assign-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-assign-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- Some functions all about type... --- count: false .panel1-is_type-auto[ ```r *is.character("hi") ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ] --- count: false .panel1-is_type-auto[ ```r is.character("hi") *is.numeric(1) ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ``` [1] TRUE ``` ] --- count: false .panel1-is_type-auto[ ```r is.character("hi") is.numeric(1) *is.integer(2.3) ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ``` [1] TRUE ``` ``` [1] FALSE ``` ] --- count: false .panel1-is_type-auto[ ```r is.character("hi") is.numeric(1) is.integer(2.3) *is.double(4L) ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ``` [1] TRUE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ] --- count: false .panel1-is_type-auto[ ```r is.character("hi") is.numeric(1) is.integer(2.3) is.double(4L) *is.integer(4) ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ``` [1] TRUE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ] --- count: false .panel1-is_type-auto[ ```r is.character("hi") is.numeric(1) is.integer(2.3) is.double(4L) is.integer(4) *is.integer(4L) ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ``` [1] TRUE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ``` [1] TRUE ``` ] --- count: false .panel1-is_type-auto[ ```r is.character("hi") is.numeric(1) is.integer(2.3) is.double(4L) is.integer(4) is.integer(4L) *is.factor("good") ``` ] .panel2-is_type-auto[ ``` [1] TRUE ``` ``` [1] TRUE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ``` [1] FALSE ``` ``` [1] TRUE ``` ``` [1] FALSE ``` ] <style> .panel1-is_type-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-is_type-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-is_type-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-as_type-auto[ ```r *as.numeric("hi") ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") *as.integer(1) ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) *as.character(2.3) ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) as.character(2.3) *as.double(4L) ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ``` [1] 4 ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) as.character(2.3) as.double(4L) *is.integer(4) ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ``` [1] 4 ``` ``` [1] FALSE ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) as.character(2.3) as.double(4L) is.integer(4) *is.integer(4L) ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ``` [1] 4 ``` ``` [1] FALSE ``` ``` [1] TRUE ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) as.character(2.3) as.double(4L) is.integer(4) is.integer(4L) *as.factor(c("good", "bad")) ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ``` [1] 4 ``` ``` [1] FALSE ``` ``` [1] TRUE ``` ``` [1] good bad Levels: bad good ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) as.character(2.3) as.double(4L) is.integer(4) is.integer(4L) as.factor(c("good", "bad")) *matrix(1:4, nrow = 2) # this is a pipe operator ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ``` [1] 4 ``` ``` [1] FALSE ``` ``` [1] TRUE ``` ``` [1] good bad Levels: bad good ``` ``` [,1] [,2] [1,] 1 3 [2,] 2 4 ``` ] --- count: false .panel1-as_type-auto[ ```r as.numeric("hi") as.integer(1) as.character(2.3) as.double(4L) is.integer(4) is.integer(4L) as.factor(c("good", "bad")) matrix(1:4, nrow = 2) %>% # this is a pipe operator # passes all of what precedes to function that follows * as.vector() ``` ] .panel2-as_type-auto[ ``` [1] NA ``` ``` [1] 1 ``` ``` [1] "2.3" ``` ``` [1] 4 ``` ``` [1] FALSE ``` ``` [1] TRUE ``` ``` [1] good bad Levels: bad good ``` ``` [1] 1 2 3 4 ``` ] <style> .panel1-as_type-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-as_type-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-as_type-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-factors-auto[ ```r *c("50", "80") ``` ] .panel2-factors-auto[ ``` [1] "50" "80" ``` ] --- count: false .panel1-factors-auto[ ```r c("50", "80") %>% * as.factor() ``` ] .panel2-factors-auto[ ``` [1] 50 80 Levels: 50 80 ``` ] --- count: false .panel1-factors-auto[ ```r c("50", "80") %>% as.factor() %>% * as.numeric() # maybe surprising ``` ] .panel2-factors-auto[ ``` [1] 1 2 ``` ] --- count: false .panel1-factors-auto[ ```r c("50", "80") %>% as.factor() %>% as.numeric() # maybe surprising *c("50", "80") ``` ] .panel2-factors-auto[ ``` [1] 1 2 ``` ``` [1] "50" "80" ``` ] --- count: false .panel1-factors-auto[ ```r c("50", "80") %>% as.factor() %>% as.numeric() # maybe surprising c("50", "80") %>% * as.factor() ``` ] .panel2-factors-auto[ ``` [1] 1 2 ``` ``` [1] 50 80 Levels: 50 80 ``` ] --- count: false .panel1-factors-auto[ ```r c("50", "80") %>% as.factor() %>% as.numeric() # maybe surprising c("50", "80") %>% as.factor() %>% * as.character() ``` ] .panel2-factors-auto[ ``` [1] 1 2 ``` ``` [1] "50" "80" ``` ] --- count: false .panel1-factors-auto[ ```r c("50", "80") %>% as.factor() %>% as.numeric() # maybe surprising c("50", "80") %>% as.factor() %>% as.character() %>% * as.numeric() # less surprising ``` ] .panel2-factors-auto[ ``` [1] 1 2 ``` ``` [1] 50 80 ``` ] <style> .panel1-factors-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-factors-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-factors-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> <style type="text/css"> .remark-code{line-height: 1.5; font-size: 100%} @media print { .has-continuation { display: block; } } </style>