zoukankan      html  css  js  c++  java
  • R语言中绘制直方图

    直方图: 直观地反映数据在不同区间的频数/频率分布。

    1、

    > dat <- c(rep(1,10), rep(2,5), rep(3,6))     ## 测试数据
    > dat
     [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3
    > hist(dat)      ## 直接绘制直方图

    一共显示了三个柱子,柱子的高度表示1.0 ~ 1.5 中的数目,  1.5 ~ 2.0中的数目,  2.5~3.0区间的数目, 也就是横坐标表示区间,纵坐标表示频数。

    2、使用break命令手动指定区间

    > dat <- c(rep(1,10), rep(2,5), rep(3,6))
    > dat
    [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3
    > hist(dat, breaks = c(0.5, 1.5, 2.5, 3.5)      ## 使用breaks指定了三个区间 0.5~1.5; 1.5~2.5; 2.5~3.5

    柱子的高度表示落在三个区间的频数。

    3、设置柱子的高度以频率显示

    > dat <- c(rep(1,10), rep(2,5), rep(3,6))
    > dat
     [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3
    > hist(dat, breaks = c(0.5, 1.5, 2.5, 3.5), freq = F)    ## 使用freq = F选项设置柱子的高度以频率显示,而不是频数

    来源:https://www.cnblogs.com/xudongliang/p/6913363.html

  • 相关阅读:
    hbase 简介
    Hadoop本地库介绍
    MapReduce:详解Shuffle过程
    eucalyptus,openstack
    openstack installing...
    今年2011
    wget代理设置(转载)
    openstack running
    python 升级到2.6(转载)
    高德地图Windowphone API学习地图定位与地图模式的切换
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15819828.html
Copyright © 2011-2022 走看看