R 语言学习笔记(二)

  1. 直方图:

     hist(data$x)
    

    hist画出的图像

  2. 散点图:

     plot(data$x)
    

    这里写图片描述

  3. 列连函数

     table(data$x)#统计次数
     0.5662 0.5663 0.5664 0.5665 0.5667 0.5669  0.567 
       140     62     47      3     12      5     10   
    
  4. 柱状图

    barplot(table(data$x))
    

    这里写图片描述

  5. 饼图

    pie(table(round(runif(20,min = 80,max=100))),radius = 3)
    

    这里写图片描述

  6. 箱尾图

     boxplot(a)
     boxplot(a,col = "red",notch = T)
     #参数boxplot(a,col = "red",notch = T,horizontal = T) 指水平放置
     #箱外两条直线,是两个四分位点,箱子中间的线是中位数,圆圈是离群点。
    

    这里写图片描述
    这里写图片描述

  7. 星相图

     stars(x[c('x1','x2','x3')])
     stars(x[c('x1','x2','x3')],draw.segments = T)
     #表示三个趋势的方向
     #面积大的代表成绩好
    #图二代表雷达图
    

    这里写图片描述

    这里写图片描述

  8. 茎叶图

     stem(x$x1)
    
      The decimal point is 1 digit(s) to the right of the |
    
       8 | 689
       9 | 000111222223333444444
       9 | 55555566666677778888888999999
      10 | 00001111111222222344
      10 | 55556666667778889999
      11 | 011234
      11 | 5
    
  9. qq图

     qqline(x1)
     qqnorm(x1)
     检验数据是否符合正态分布
    
  10. plot()

    plot(x1,x2,main='math scores',xlab='math analysis', ylab='linear algebra', xlim=c(50,100), ylim=c(50,100), xaxs='i', yaxs='i',col='red',pch=19)
    #pch=19 代表使用实圆点
    #type='l'代表连线
    

    这里写图片描述

    在plot基础上继续画图
    使用lines命令,lines参数同plot
    
  11. 查看内置数据集

     data()
    
  12. 热力图:heatmap()

      heatmap(as.matrix(mtcars),Rowv = NA,Colv = NA,col=heat.colors(256),scale = 'column',margins = c(2,8),main="Car characteristic by model")
    
    #颜色越浅,数值越大
    

    这里写图片描述

  13. 散点图集

    pairs(iris[,1:4])
    #两两配对画图
    

    这里写图片描述

  14. par

    #在同一个device输出多个图
    par(mfrow=c(3,1))
    
  15. 图形窗的操作

    dev.new()#建立新的图形窗
    dev.list()#查看存在的图形窗
    dev.cur()#查看当前的图形窗
    dev.next()#切换图形窗
    
  16. 地图

        library(maps)
        map("state",interior = F)
    

    这里写图片描述

        map("state", boundary = F,col = 'red',add=T)
    

    这里写图片描述

         map("world", fill = T, col = heat.colors(10))
    

    这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值