> ls()
character(0)
> n <- 5
> ls()
[1] "n"
> x <- "acgt"
> ls() ## 查看内存中所有变量名
[1] "n" "x"
> str(n) ## 查看数据结构
num 5
> str(x)
chr "acgt"
> ls.str() ## 查看所有变量的数据类型
n : num 5
x : chr "acgt"
> ls()
[1] "n" "x"
> rm(n) ## 删除变量对象
> ls()
[1] "x"
> rm(list=ls()) ## 删除所有变量对象
向量 (vector)
> x <- c(2, 6.6, 9.6)
> x
[1] 2.0 6.6 9.6
> y <- 2.2:5.2
> y
[1] 2.2 3.2 4.2 5.2
> c(x, y) ## 向量
[1] 2.0 6.6 9.6 2.2 3.2 4.2 5.2
> 1:10
[1] 1 2 3 4 5 6 7 8 9 10
> x <- 1:5
> mode(x) ## 数据结构的一个属性,查看成员数据类型
[1] "numeric"
> length(x) ## 成员个数
[1] 5
> y <- c(FALSE, TRUE)
> y
[1] FALSE TRUE
> mode(y)
[1] "logical"
> length(y)
[1] 2
> 1 > 0
[1] TRUE
> z <- c("order", "family", "genus", "species")
> mode(z)
[1] "character"
> length(z)
[1] 4
> z
[1] "order" "family" "genus" "species"
> z[1:2] ## 索引切片法
[1] "order" "family"
> i &