Type coercion

Author

Mine Çetinkaya-Rundel

c(1, 1L, "C")
[1] "1" "1" "C"
1
[1] 1
1L
[1] 1
"C"
[1] "C"
#typeof(c(1, 1L, "C"))
c(1L / 0, "A")
[1] "Inf" "A"  
typeof(1L)
[1] "integer"
typeof(0)
[1] "double"
typeof(1L/0)
[1] "double"
typeof("A")
[1] "character"
#typeof(c(1L / 0, "A"))
c(1:3, 5)
[1] 1 2 3 5
typeof(1:3)
[1] "integer"
typeof(5)
[1] "double"
#typeof(c(1:3, 5))
c(3, "3+")
[1] "3"  "3+"
typeof(3)
[1] "double"
typeof("3+")
[1] "character"
#typeof(c(3, "3+"))
c(NA, TRUE)
[1]   NA TRUE
typeof(NA)
[1] "logical"
typeof(TRUE)
[1] "logical"
#typeof(c(NA, TRUE))