step

R-总结

文件设置

列出当前工作空间目录下的文件

> list.files()
 [1] "Default.rdp"                          
....
> dir()
 [1] "Default.rdp"                          
 [2] "desktop.ini"                          
...

获取当前工作路径

> getwd()
[1] "c:/"

设置当前工作路径:

> setwd("d:/我的文档")

退出并保持当前工作空间

> q()

通过args查看函数的所有参数

> args(list.files)
function (path = ".", pattern = NULL, all.files = FALSE, 
    full.names = FALSE, recursive = FALSE, ignore.case = FALSE, 
    include.dirs = FALSE, no.. = FALSE) 
NULL

获取当前工作目录并赋值给old.dir

> old.dir <- getwd()

在当前工作目录想创建一个文件

> dir.create("testdir")

列出当前目录下的文件

> list.files()
[1] "mytest.R"

使用file.info()来查看文件信息

> file.info("mytest.R")
         size isdir mode               mtime               ctime
mytest.R    0 FALSE  666 2019-10-29 09:05:20 2019-10-29 09:02:31
                       atime exe
mytest.R 2019-10-29 09:05:20  no

数据类型

一共五种基本数据类型,分别是:

  1. 数值型:numeric
  2. 逻辑型:logical
  3. 字符型:character
  4. 负数型:complex
  5. i整数型:nteger

    判断并查看数据类型

    numeric:

    > x1 <- c(1,2,3,4)
    > is.numeric(x1)
    [1] TRUE
    > x2 <- TRUE
    > is.logical(x2)
    [1] TRUE
    > x3 <- c("weijiew.com")
    > is.character(x3)
    [1] TRUE
    > is.numeric(x3)
    [1] FALSE
    > x4 <- c(2i)
    > is.complex(x4)
    [1] TRUE
    > x5 <- c(1L)
    > is.integer(x5)
    [1] TRUE
    >  class(x1)
    [1] "numeric"
    > class(x2)
    [1] "logical"
    > mode(x3)
    [1] "character"
    > typeof(x4)
    [1] "complex"
    > data <- data.frame(c1 = c(1,2,3),c2 = 1:3, c3=TRUE , c4="mingtian")
    > sapply(data,mode)
       c1        c2        c3        c4 
    "numeric" "numeric" "logical" "numeric" 
    > sapply(data,clas)
    Error in match.fun(FUN) : 找不到对象'clas'
    > sapply(data,class)
       c1        c2        c3        c4 
    "numeric" "integer" "logical"  "factor" 
    > sqpply(data,typeof)
    Error in sqpply(data, typeof) : 没有"sqpply"这个函数
    > sapply(data,typeof)
       c1        c2        c3        c4 
    "double" "integer" "logical" "integer" 
    > 

    数据类型之间的转换

    转换 : as.数据类型() 判断:is.数据类型() sapply(参数,data/typeof/mode)

    > x6 <- c(1,2,3,4)
    > sapply(x6,class)
    [1] "numeric" "numeric" "numeric" "numeric"
    > x7 <- as.character(x6)
    > sapply(x7,class)
          1           2           3           4 
    "character" "character" "character" "character" 

    向量

    c

    创建向量,使用c函数创建向量,同一向量中数据类型必须一致。

    > x8 <- 1:5
    > x8
    [1] 1 2 3 4 5
    > x9 <- c(1,2,3)
    > x9
    [1] 1 2 3

    seq(Sequence)

    seq(from = 首项,to = 尾项,by = 步长,length.out = 长度,along.with = 指向另一个向量的长度,表示此向量与另一个向量长度相同)

    > seq(0,10,by=0.5)

    起始是0,结尾是10,by设置的是步长,步长是0.5。

    > my_seq <- seq(5,10,length=30)

    设定长度为30,然后自动计算步长输出。

> a1 <- seq(1,11,2)
> a1
[1]  1  3  5  7  9 11
> a1 <- seq(1,11,length.out=6)
> a1
[1]  1  3  5  7  9 11
> a1 <- seq(1,11,by=6)
> a1
[1] 1 7
> a1 <- seq(1,11,length.out=2)
> a1
[1]  1 11
> a2 <- seq(1,8,along.with = a1)
> a2
[1] 1 8
> a3 <- seq(1,8,by=4)
> a3
[1] 1 5
> a4 <- seq(1,8,length.out=2)
> a4 
[1] 1 8

rep(Replicate)

Replicate:复制。 rep(数列,times = 整体重复次数,each = 单个重复次数,length.out = 数列长度)

> a4 <- seq(1,8,2)
> a4
[1] 1 3 5 7
> a5 <- rep(a4,3)
> a5
 [1] 1 3 5 7 1 3 5 7 1 3 5 7
> a6 <- rep(a4,each=3)
> a6
 [1] 1 1 1 3 3 3 5 5 5 7 7 7
> a7 <- rep(a4,times=3)
> a7
 [1] 1 3 5 7 1 3 5 7 1 3 5 7
> a8 <- rep(a4,length.out = 8)
> a8
[1] 1 3 5 7 1 3 5 7
> a8 <- rep(a4,length.out = 7)
> a8
[1] 1 3 5 7 1 3 5
> rep(c(0,1,2),times = 10)
 [1] 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1
[24] 2 0 1 2 0 1 2

0,1,2整体复制十次

> rep(c(0,1,2),each= 10)
 [1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2
[24] 2 2 2 2 2 2 2

0,1,2每一个单独复制十次

c

> num_vect <- c(0.5,55,-10,6)

用c函数创建一个向量

> tf <- num_vect < 1

tf中存放的是num_vect中每一个数对应条件的逻辑值

> my_char <- c("My","name","is")

创建一个字符向量

> my_char
[1] "My"   "name" "is"  

查看这个字符向量

> paste(my_char,collapse = " ")
[1] "My name is"

将字符向量中的字符合并以空格分隔

> my_name<-c(my_char,"your_name_here")
> my_name
[1] "My"             "name"          
[3] "is"             "your_name_here"

拼接字符串

> paste(my_name,collapse = " ")
[1] "My name is your_name_here"

> paste("Hello","world!",sep=" ")
[1] "Hello world!"

> paste(c("X","Y","Z"),sep=" ")
[1] "X" "Y" "Z"

> paste(1:3,c("X","Y","Z"),sep=" ")
[1] "1 X" "2 Y" "3 Z"

> paste(1:3,c("X","Y","Z"),sep="")
[1] "1X" "2Y" "3Z"

> paste(LETTERS,1:4,sep="-")
 [1] "A-1" "B-2" "C-3" "D-4" "E-1" "F-2" "G-3"
 [8] "H-4" "I-1" "J-2" "K-3" "L-4" "M-1" "N-2"
[15] "O-3" "P-4" "Q-1" "R-2" "S-3" "T-4" "U-1"
[22] "V-2" "W-3" "X-4" "Y-1" "Z-2"

将字符向量合并成一个并用空格隔开 LETTERS是R中预定义的,指A-Z

> x[is.na(x)]

打印出x中所有的Na值

> y <- x[!is.na(x)]
> y
 [1] -0.2350558 -0.2479688 -0.6450823 -0.4085304
 [5]  0.1959802  0.5181858  1.0478624  1.3596186
 [9] -0.6933137 -0.9564063  2.8779701 -1.6199365
[13] -0.2687278  0.8495834  0.1961917  1.6297820
[17]  0.2874848  0.2741789  0.1362384  1.5872867

将x中所有不是na的值打印出来并赋值给y

> x
 [1]         NA -0.2350558         NA -0.2479688
 [5] -0.6450823 -0.4085304         NA         NA
 [9]  0.1959802         NA  0.5181858  1.0478624
[13]  1.3596186 -0.6933137         NA         NA
[17] -0.9564063  2.8779701         NA         NA
[21] -1.6199365         NA -0.2687278  0.8495834
[25]         NA         NA  0.1961917  1.6297820
[29]         NA  0.2874848         NA  0.2741789
[33]         NA  0.1362384         NA         NA
[37]         NA         NA         NA  1.5872867
> x[x>0]
 [1]        NA        NA        NA        NA
 [5] 0.1959802        NA 0.5181858 1.0478624
 [9] 1.3596186        NA        NA 2.8779701
[13]        NA        NA        NA 0.8495834
[17]        NA        NA 0.1961917 1.6297820
[21]        NA 0.2874848        NA 0.2741789
[25]        NA 0.1362384        NA        NA
[29]        NA        NA        NA 1.5872867
> x[x<0]
 [1]         NA -0.2350558         NA -0.2479688
 [5] -0.6450823 -0.4085304         NA         NA
 [9]         NA -0.6933137         NA         NA
[13] -0.9564063         NA         NA -1.6199365
[17]         NA -0.2687278         NA         NA
[21]         NA         NA         NA         NA
[25]         NA         NA         NA         NA
> x[!is.na(x) & x>0]
 [1] 0.1959802 0.5181858 1.0478624 1.3596186
 [5] 2.8779701 0.8495834 0.1961917 1.6297820
 [9] 0.2874848 0.2741789 0.1362384 1.5872867

x[x>0] 把x中小于零的数字剔除,x[x<0]把x中大于零的数字剔除。 x[!is.na(x) & x>0]把x中小于零和na值剔除。

> x[c(3,5,7)]
[1] -0.8349965 -0.1248848         NA
> x[0]
numeric(0)
> x[c(-2,-10)]
 [1] -1.6075546 -0.8349965 -1.6337176 -0.1248848
 [5]         NA         NA -0.4736692         NA
 [9]         NA -0.6819199 -0.5073136  0.9675951
[13]  1.2769949  1.4313526         NA         NA
[17]         NA         NA -1.1528907         NA
[21]         NA  1.9626638 -0.9895084         NA
[25]         NA         NA -0.5197052         NA
[29]         NA         NA -1.0084469         NA
[33] -0.1174404  0.9598553  2.5671915         NA
[37]         NA  1.1656769
>  x[-c(2,10)]
 [1] -1.6075546 -0.8349965 -1.6337176 -0.1248848
 [5]         NA         NA -0.4736692         NA
 [9]         NA -0.6819199 -0.5073136  0.9675951
[13]  1.2769949  1.4313526         NA         NA
[17]         NA         NA -1.1528907         NA
[21]         NA  1.9626638 -0.9895084         NA
[25]         NA         NA -0.5197052         NA
[29]         NA         NA -1.0084469         NA
[33] -0.1174404  0.9598553  2.5671915         NA
[37]         NA  1.1656769

使用c函数创建索引,索引会从1开始,而非0。 x[c(-2,-10)]拿到除了2-10之间所有的元素且x[-c(2,10)]与之等效

向量索引

通过下标索引:

> a9[1:8]
[1] 1 2 3 4 5 6 7 8
> a10 <- c(1,5)
> a10
[1] 1 5
> a9 
[1] 1 2 3 4 5 6 7 8
> a9[c(1,4,5)]
[1] 1 4 5
> a9[-1]
[1] 2 3 4 5 6 7 8
> a9[-2]
[1] 1 3 4 5 6 7 8
> a9[-c(1:3)]
[1] 4 5 6 7 8
> a9[c(TRUE,TRUE,FALSE,FALSE,FALSE)]
[1] 1 2 6 7

which索引

> x1<-c(1:9)//创建序列
> x1
[1] 1 2 3 4 5 6 7 8 9
> which(x1==1)//找出序列中等于1的位置
[1] 1
> which(x1==1|x1==5)//找出序列中等于1或等于5 的位置
[1] 1 5
> which(x1>1|x1 < 5)
[1] 1 2 3 4 5 6 7 8 9
> which(x1>1&x1 < 5)
[1] 2 3 4
> which.max(x1)//找出序列中最大值
[1] 9
> which.min(x1)
[1] 1

向量编辑

append():向量后面补充

> x1 <- c(1:9)//创建向量
> x1
[1] 1 2 3 4 5 6 7 8 9
> x2 <- c(x1,c(10:20))//追加10个元素
> x2
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
> x3 <- append(x2,c(21:30))//另一种追加方式
> x3
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
> x3 <- append(x2,c(21:30),0)//新增加的参数是追加的位置
> x3
 [1] 21 22 23 24 25 26 27 28 29 30  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
> x3[1] <- 1//更新1位置的数为1
> x3[2] <- 2
> x3
 [1]  1  2 23 24 25 26 27 28 29 30  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
> x1[1:5] <- c(1:5)//更新一段位置
> x1
[1] 1 2 3 4 5 6 7 8 9
> x3[1:5] <- c(1:5)
> x3
 [1]  1  2  3  4  5 26 27 28 29 30  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
> x1 <- x1[-1]//删除位置1的向量
> x1
[1] 2 3 4 5 6 7 8 9

向量排序

sort(序列名,升序为TRUE降序为FALSE,对na值的处理)排序

> sort(x3,TRUE)
 [1] 30 29 28 27 26 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  5  4  4  3  3  2  2  1  1
> x3
 [1]  1  2  3  4  5 26 27 28 29 30  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
> x3[31] = NA
> x3
 [1] 30 29 28 27 26 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  5  4  4  3  3  2  2  1  1 NA
> sort(x3,TRUE,na.last = TRUE)
 [1] 30 29 28 27 26 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  5  4  4  3  3  2  2  1  1 NA
> sort(x3,TRUE,na.last = FALSE)
 [1] NA 30 29 28 27 26 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  5  4  4  3  3  2  2  1  1 

数据框

创建数据框

模型

name1 <- c(data1,data2,data3,data4)//创建数据对象
name2 <- c(data1,data2,data3,data4)
name3 <- c(data1,data2,data3,data4)
table <- data.frame(name1,name2,name3)//转换成表格

例子

> x1 <- c(1:4)
> x1
> x2 <- c(2:5)
> x3 <- c(3:6)
> x4 <-data.frame(x1,x2,x3)
> x4
  x1 x2 x3
1  1  2  3
2  2  3  4
3  3  4  5
4  4  5  6

数据框索引

模型

table [,1]//显示第一列的数据
table [1,]//显示第一行的数据
subset(table,name1=="condition") //冒号里面为条件,输出这一行的数据

例子

> x1 <- c(1:4)
> x1
[1] 1 2 3 4
> x2 <- c(2:5)
> x3 <- c(3:6)
> x4 <-data.frame(x1,x2,x3)
> x4
  x1 x2 x3
1  1  2  3
2  2  3  4
3  3  4  5
4  4  5  6
> x4[,1]
[1] 1 2 3 4
> subset(x4,x1="1")
  x1 x2 x3
1  1  2  3
2  2  3  4
3  3  4  5
4  4  5  6
> subset(x4,x1=="1")
  x1 x2 x3
1  1  2  3
> subset(x4,x2=="1")
[1] x1 x2 x3
> subset(x4,x2=="3")
 x1 x2 x3
2  2  3  4

列表

创建列表

> data <- list(a = c(1:5),b=c("a1","a2","a3"),c=c("true","false"))
> data
$a
[1] 1 2 3 4 5

$b
[1] "a1" "a2" "a3"

$c
[1] "true"  "false"

> summary(data)
  Length Class  Mode     
a 5      -none- numeric  
b 3      -none- character
c 2      -none- character
> data[[3]]
[1] "true"  "false"
> data[[1]]
[1] 1 2 3 4 5
> data[[2]]
[1] "a1" "a2" "a3"
> data[["a"]]
[1] 1 2 3 4 5
> 

删除列表

> data$a <-NULL //删除a列
> data
$b
[1] "a1" "a2" "a3"

$c
[1] "true"  "false"
> data$b<-NULL//删除b列
> data$c<-NULL
> data
named list()
> data1 <- c(data,list(e= c(1:5)))//列增加
> data1
$e
[1] 1 2 3 4 5

> data1 <- c(data1,list(a=c(1:5)))
> data1
$e
[1] 1 2 3 4 5

$a
[1] 1 2 3 4 5

> data1 <- c(data1,list(b = c(1:5)))
> data1
$e
[1] 1 2 3 4 5

$a
[1] 1 2 3 4 5

$b
[1] 1 2 3 4 5

> data1 <- c(data1,list(c=c(1:5)))
> data1
$e
[1] 1 2 3 4 5

$a
[1] 1 2 3 4 5

$b
[1] 1 2 3 4 5

$c
[1] 1 2 3 4 5

总结:

  1. getwd()/setwd() 查看并设置工作路径。
  2. is.numeric()/as.numeric 判断并转换数据类型。
  3. c()/seq()/rep() 创建向量
  4. which()索引,下标索引,matrix()创建矩阵。

矩阵

创建矩阵

matrix

> a <- matrix(c(1:4,2:5,3:6,4:7),ncol=4,nrow = 4)
> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    2    3    4    5
[3,]    3    4    5    6
[4,]    4    5    6    7

创建单位矩阵

diag

> diag(x=1,nrow = 4,ncol = 4)
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    0    1    0    0
[3,]    0    0    1    0
[4,]    0    0    0    1

创建零矩阵

diag

> e <- diag(x=0,nrow = 3,ncol = 3)
> e
     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

创建对角矩阵

diag

> e <- diag(1:4,ncol = 4,nrow=4)
> e
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    0    2    0    0
[3,]    0    0    3    0
[4,]    0    0    0    4

创建上/下三角矩阵

lower,tre()

> a[lower.tri(a,diag = FALSE)] <- 0
> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    0    3    4    5
[3,]    0    0    5    6
[4,]    0    0    0    7

upper.tri()

> a[upper.tri(a,diag = FALSE)] <- 0
> a
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    2    3    0    0
[3,]    3    4    5    0
[4,]    4    5    6    7

矩阵转置

> a
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    2    3    0    0
[3,]    3    4    5    0
[4,]    4    5    6    7
> a <- t(a)
> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    0    3    4    5
[3,]    0    0    5    6
[4,]    0    0    0    7

求行列式的值

> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    0    3    4    5
[3,]    0    0    5    6
[4,]    0    0    0    7
> det(a)
[1] 105

矩阵求逆

solve

> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    0    3    4    5
[3,]    0    0    5    6
[4,]    0    0    0    7
> solve(a)
     [,1]       [,2]        [,3]        [,4]
[1,]    1 -0.6666667 -0.06666667 -0.03809524
[2,]    0  0.3333333 -0.26666667 -0.00952381
[3,]    0  0.0000000  0.20000000 -0.17142857
[4,]    0  0.0000000  0.00000000  0.14285714

矩阵求秩

> a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    0    3    4    5
[3,]    0    0    5    6
[4,]    0    0    0    7
> qr(a)$rank
[1] 4

求解特征值和特征向量

eigen

> eigen(a)
eigen() decomposition
$values
[1] 7 5 3 1

$vectors
          [,1]      [,2]      [,3] [,4]
[1,] 0.5602873 0.6163156 0.7071068    1
[2,] 0.6645268 0.7043607 0.7071068    0
[3,] 0.4690778 0.3521804 0.0000000    0
[4,] 0.1563593 0.0000000 0.0000000    0

正交矩阵

t(a)%*%a = E

> c <- matrix(c(sqrt(2)/2,-sqrt(2)/2,sqrt(2)/2,sqrt(2)/2),nrow = 2)
> c
           [,1]      [,2]
[1,]  0.7071068 0.7071068
[2,] -0.7071068 0.7071068
> value <- t(c)%*%c
> value
     [,1] [,2]
[1,]    1    0
[2,]    0    1

基本图形

使用图形

//绑定mtcars这个数据集
> attach(mtcars)
//以x轴为wt(重量),y轴mpg(耗油加仑量)为坐标画图
> plot(wt,mpg)
//画出散点图的拟合曲线
> abline(lm(mpg~wt))
//增加标题
> title("sss")
//取消绑定
> detach(mtcars)

以文件形式输出保存d

在代码开头结尾加上

> pdf("project_name")
> 代码块
> dev.off

例子:

> pdf("mypicture.pdf")
> attach(mtcars)
> plot(wt,mpg)
> abline(lm(mpg~wt))
> title("sss")
> detach(mtcars)
> dev.off

plot

> dose <- c(20,30,40,45,60)
> drugA <- c(16,20,27,40,60)
> drugB <- c(15,18,25,31,40)
> plot(dose,drugA)

只绘制点:

> plot(dose,drugA)

绘制点和线

> plot(dose,drugA,type = "b")

只绘制线

> plot(dose,drugA,type = "c")

条形图

create a bar plot wiht vertial or horizontal bars barplot()

> a <- c(1,2,3)
> a
[1] 1 2 3
> barplot(a,main = "main",xlab = "x",ylab = "y")

箱线图

boxplot()

> boxplot(mpg~cyl,data = mtcars,main="mian",xlab="xlab",ylab="ylab")
> boxplot(mpg~cyl,data = mtcars,notch=TRUE,col="red",main="mian",xlab="xlab",ylab="ylab")

小提琴图

> library(vioplot)
> x1 <- mtcars$mpg[mtcars$cyl==4]
> x2 <- mtcars$mpg[mtcars$cyl==6]
> x3 <- mtcars$mpg[mtcars$cyl==8]
> vioplot(x1,x2,x3,names=c("x1","x2","x3"),col="gold")
[1] 10.4 33.9
> title("thi is a title")

散点图

散点图矩阵

> pairs(~mpg + disp + drat + wt,data = mtcars,main="s")

上三角:

> pairs(~mpg + disp + drat + wt,data = mtcars,main="s",upper.panel = NULL)

另一种创建散点矩阵的方式:

> scatterplotMatrix(~mpg+disp+drat+wt,data = mtcars,spread = FALSE,lty.smooth = 2,main="sss")

高密度散点图

> set.seed(1234)
> n <- 10000
> c1 <- matrix(rnorm(n,mean = 0,sd=.5),ncol = 2)
> c2 <- matrix(rnorm(n,mean = 3,sd=2),ncol = 2)
> mydata<- rbind(c1,c2)
> mydata<-as.data.frame(mydata)
> names(mydata) <- c("x","y")
> with(mydata,plot(x,y,pch=19,main = "main"))

我们会发现点很密集不易观察。 smoothScatter:

with(mydata,smoothScatter(x,y,main = "main"))

3d散点图

> library(scatterplot3d)
> attach(mtcars)
> scatterplot3d(wt,disp,mpg,main = "3d")

增强纵深,加上标线

> scatterplot3d(wt,disp,mpg,pch=16,highlight.3d = TRUE,type ="h",  main = "3d")

添加回归平面

> s3d <- scatterplot3d(wt,disp,mpg,pch=16,highlight.3d = TRUE,type ="h",  main = "3d")
> fit <- lm(mpg~wt+disp)
> s3d$plane3d(fit)

rgl

> library(rgl)
> plot3d(wt,disp,mpg,col = "red",size=5)
> plot3d(wt,disp,mpg,xlab = "xxxx",ylab = "yyy",zlab = "zzz",main = "main", col = "red",size=5)

Rcmdr

> library(Rcmdr)
> attach(mtcars)
> scatter3d(mt,disp,mpg)

折线图

不加type参数是散点图,加上是折线图,不同参数对应不同折线。

> plot(t1$age,t1$circumference,xlab = "xx",ylab = "yy",main = "main")
> plot(t1$age,t1$circumference,xlab = "xx",ylab = "yy",main = "main",type = "b")
Tagged with R 语言

Posted December 15, 2019


WIJE picweijiew . github