R 语言学习笔记(二)

来源:互联网 发布:火箭爵士季后赛数据 编辑:程序博客网 时间:2024/05/17 23:51
  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))

    这里写图片描述

0 0
原创粉丝点击