--- title: "Primitve Data Types in R" output: html_notebook --- + integer (subclass of numeric) + numeric (double) + complex + character ('a', "hello") + logical (TRUE/FALSE) + raw (byte level) ```{r} v <- 1L class(v) v <- 1 class(v) v <- 1 + 1i class(v) v <- "a string" class(v) v<-'a' class(v) v<-TRUE class(v) ``` see also [R Manual](http://stat.ethz.ch/R-manual/R-devel/doc/manual/R-lang.html#Objects) for mode(), storage.mode(), typeof() ## Assignment: <- or = ```{r} median(x = 1:10) x ## Error: object 'x' not found ``` see [R Manual](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/median.html) ```{r} median(x <- 1:10) x ## [1] 1 2 3 4 5 6 7 8 9 10 ``` Scope! ```{r} x <- 5 x `<-`(x, 6) #same thing x y = 5 y `=`(y, 6) #also the same thing y ``` But! ```{r} x <- y <- 5 # `<-`(x, `<-`(y, 5)) x y ``` ```{r} x <- y = 5 x y # `=`(`<-`(x, y), 5) not `<-`(x, `=`(y, 5)) ``` Why? Just because = is of lower precedence than <-. ```{r} x = y = 5 # `=`(x, `=`(y, 5)) x y ```