Preface

Maybe these methods are quite useful when dealing with the “assignment for Statistics”. —— GGN_2015 from Jilin University

Auto Install Package – pacman

# "pacman" is a package which can install packages automatically when the required package is not found.
install.packages("pacman")# After "pacman" is installed, use the following code to autoload library "qcc"
library(pacman)
p_load(qcc)

Histogram

Here is a simple method to plot a Histogram with no packages required.

# Use R language to create a histogram
d = c(62,68,69,80,68,79,83,70,74,73,74,75,80,77,80,83,73,79,100,93,92,101,87,96,99,94,102,95,90,98,86,93,91,90,95,97,87,89,100,93,92,98,101,97,102,91,87,110,106,118)
hist(d, xlab = "Temperature", col = "white", border = "black", breaks = seq(60, 120, 10), right = TRUE, main = "Histogram for Temperature")
  • xlab set the title of X axis;
  • col set the color of bars in histogram;
  • border set the color of the border of bars;
  • breaks set the data range of each bar;
    • the left-most and right-most point must contain all the values in data set;
  • right = TRUE to set data range of each bar as Left-Open& Right-Closed;
  • main set the title of the whole diagram.

Pareto Diagram

# Please make sure that package "pacman" is installed before you run this program.
library(pacman)# if there is no "qcc", install and load, otherwise load directly.
p_load(qcc)# data set vector "Waste" (ordered it yourself)
Wastes= c(75, 31, 22, 8)# give names to each column of vector "Wastes"
names(Wastes) = c('Plastic', 'Irom', 'Clothes', 'Spares') # plot a pareto diagram
pareto.chart(Wastes, ylab="Waste Amount",  # left-side-labelcol = "white", # set the color of bars# cumperc = seq(0, 120, by = 5),  # coordinate on the Rightylab2 = "Acummulative Percentage", # right-side-labelmain = "Perato Diagram" # Title of the
)

Scattered Diagram

x_data = c(2.62,2.875,2.32,3.215,3.44,3.46,3.57,3.19,3.15,3.44,3.44,4.07,3.73,3.78,5.25,5.424,5.345,2.2,1.615,1.835,2.465,3.52,3.435,3.84,3.845,1.935,2.14,1.513,3.17,2.77,3.57,2.78)
y_data = c(21,21,22.8,21.4,18.7,18.1,14.3,24.4,22.8,19.2,17.8,16.4,17.3,15.2,10.4,10.4,14.7,32.4,30.4,33.9,21.5,15.5,15.2,13.3,19.2,27.3,26,30.4,15.8,19.7,15,21.4)
plot(x_data, y_data, ylab = "y data", xlab = "x data", main = "Scattered Diagram", type = "p")# Use least-squares-method to get the linear relationship and show it on screen
abline(lm(y_data ~ x_data))
  • type="p" create a dot diagram;
  • type="l" create a broken line diagram;
  • type="o" create a broken line diagram with dots between lines.

Using R Language to Plot Diagrams相关推荐

  1. R语言使用plot函数和lines函数可视化线图(line plot)时、图之间的主要区别是由选项type产生的、type参数常用参数说明、不同type生成的可视化图像对比

    R语言使用plot函数和lines函数可视化线图(line plot)时.图之间的主要区别是由选项type产生的.type参数常用参数说明.不同type生成的可视化图像对比 目录

  2. R语言使用R原生函数plot和lines可视化线图、并使用lty参数自定义线条类型、lwd自定义设置线条的粗细、col参数自定义线条颜色(Change R base plot line types)

    R语言使用R原生函数plot和lines可视化线图.并使用lty参数自定义线条类型.lwd自定义设置线条的粗细.col参数自定义线条颜色(Change R base plot line types) ...

  3. R语言使用plot函数可视化数据散点图,使用title函数为可视化图像设置自定义标题名称、自定义adj参数将标题向右侧移动

    R语言使用plot函数可视化数据散点图,使用title函数为可视化图像设置自定义标题名称.自定义adj参数将标题向右侧移动 目录

  4. R语言可视化plot函数中不同lwd参数对应的线条粗细的差异、进行对比可视化

    R语言可视化plot函数中不同lwd参数对应的线条粗细的差异.进行对比可视化 目录 R语言可视化plot

  5. R语言使用plot函数可视化数据、使用pch参数设置数据点的形状、使用lwd参数和bg参数设置数据点边框宽度、背景颜色(仅限于 21到25)

    R语言使用plot函数可视化数据.使用pch参数设置数据点的形状.使用lwd参数和bg参数设置数据点边框宽度.背景颜色(仅限于 21到25) 目录

  6. R语言使用plot函数可视化数据、使用type参数自定义设置可视化的类型(数据点和线关系的类型)、设置type参数为s则为阶梯状显示

    R语言使用plot函数可视化数据.使用type参数自定义设置可视化的类型(数据点和线关系的类型).设置type参数为s则为阶梯状显示 目录

  7. R语言可视化plot函数中不同lty参数对应的线条类型(实现、虚线、点线)、对比可视化不同线条类型的差异

    R语言可视化plot函数中不同lty参数对应的线条类型(实现.虚线.点线).对比可视化不同线条类型的差异 目录

  8. R语言使用plot函数可视化数据散点图,使用cex.sub参数自定义设置次标题的字体大小(subtitle)

    R语言使用plot函数可视化数据散点图,使用cex.sub参数自定义设置次标题的字体大小(subtitle) 目录

  9. R语言使用plot函数可视化数据散点图,使用cex.lab参数自定义设置坐标轴标签字体的大小(axis labels)

    R语言使用plot函数可视化数据散点图,使用cex.lab参数自定义设置坐标轴标签字体的大小(axis labels) 目录

最新文章

  1. 统一建模语言(UML)介绍
  2. 将项目导入myeclipse后 tortoise svn 右键项目不能更新和提交
  3. 《MATLAB图像处理375例》——1.8 MATLAB程序流程控制结构
  4. Server.MapPath()的用法
  5. RancherOS v1.5.0发布
  6. 网页防篡改技术_阿里云云安全中心和web应用防火墙的网页防篡改功能有什么不同...
  7. HTML资源嗅探,scrapy-2 嗅探网站,解析HTML
  8. PS CS6启动“不能打开暂存盘文件”的解决方法
  9. 在Deepin v20系统中安装RTL8821CE无线网卡驱动的步骤
  10. 艺龙深耕酒店VS携程 布局旅游全产业
  11. 记录自己需要读的几本书
  12. vue2.0中的退出登录问题
  13. 关于nomogram核心函数的time.inc函数的设定
  14. 2016年下半年信息安全工程师上午选择题及解析
  15. u8系统服务器已停止怎么办,紧急通知!用友U8报错:enterpriseportal 已停止工作的解决办法!...
  16. 应届生和往届生,谁更容易考研成功?
  17. 【数据库-MySql】单姓第二字用*号代替,复姓第三个字用*号代替。
  18. c语言中的除法求商例题,除法算式求商的方法 教案
  19. 一阶广义差分模型_4.2 序列相关性_清华大学:计量经济学(李子奈博导)_ppt_大学课件预览_高等教育资讯网...
  20. 一日一技:看视频用这个太爽了!自动实时翻译英语视频

热门文章

  1. AE 图层分解与动画循环
  2. 如何用Python投机倒把几天“暴富”
  3. poj 1950 Dessert 深搜
  4. Excel的数据可视化和Python的有什么不同?
  5. 在线选课系统UML大作业
  6. Linux ALSA音频驱动之一:框架概述
  7. 终于找到了T5L串口屏按键值不能上传的原因
  8. 关于微服务和 Java 需要知道的 5 件事
  9. baby计算机英语怎么读,英语单词baby怎么读,baby的音标是什么,baby是什么意思 - 音标网...
  10. 《Redis设计与实现》笔记|SDS动态字符串|链表字典跳跃表整数集合压缩列表结构|redis中的对象|数据库原理|RDB持久化|AOF持久化|事件与多路利用模型|发布订阅原理|事务原理|慢查询日志