2.1 Variables

2.1.1 Assignment (赋值)

x <- 5
x = 4
x <- y <- 3

2.1.2 Naming (变量命名)

2.2 Basic Data Types

In R, there are 6 atomic types: integer, double, logical, character, complex, raw.

Numeric contains integer and double.

You can use function typeof(var_name) or is.xxx(x) to check the variable’s type.

> typeof(1)
[1] "double"

> typeof(1L)
[1] "integer"

> typeof("qqq")
[1] "character"

> typeof(TRUE)
[1] "logical"

> is.integer(1)
[1] FALSE

> is.integer(1L)
[1] TRUE

2.2.1 Numeric: integer & double (数值类型)

2.2.2 Logical (布尔类型)