关于R基础

有3个需要总结的地方

  1. R的画图(统计学图,ggplot)
  2. R的基本语法
  3. R dataframe相关

Plot

plot(1,2)
plot(c(1, 2, 3, 4, 5), c(3, 7, 8, 9, 12)) x <- c(1, 2, 3, 4, 5)
y <- c(3, 7, 8, 9, 12)
plot(x, y)

其他参数:

  • type='l'
  • main="My Graph"
  • xlab="The x-axis"
  • ylab="The y axis"
  • col="red"
  • cex=2, 点的大小,默认值为1。
  • pch=25 形状(值从0-25)
  • lwd=2 如果画的不是line,也会起作用
  • lty=3 linestyle, 只有在type=line的时候才会起作用 (值从0-6)
  • 0 removes the line
  • 1 displays a solid line
  • 2 displays a dashed line
  • 3 displays a dotted line
  • 4 displays a "dot dashed" line
  • 5 displays a "long dashed" line
  • 6 displays a "two dashed" line
#画两条线,一定是先plot后line

line1 <- c(1,2,3,4,5,10)
line2 <- c(2,5,7,8,9,10) plot(line1, type = "l", col = "blue")
lines(line2, type="l", col = "red")

看完了line

abline(lm(y~x))

  • abline 画回归线
  • lm() linear-model 用线性模型拟合回归线

title("AAA")

给图像添加题目

ggplot

library(ggplot) 

ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = class))

#区别
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = "blue")) ggplot(data = diamonds) + geom_bar(aes(x = cut, fill = cut)) + scale_fill_brewer(palette = "Dark2") ggsave(file = "mygraph.png", plot = p)
  • geom_smooth()

R的画图的更多相关文章

  1. R 语言画图的基本参数

    R 语言画图的基本参数 点 点的种类 点的种类参数为 pch,每一种符号对应一个数字编号 # 点有25种,为了展示25种点 x = 1:25 y = 1:25 x ## [1] 1 2 3 4 5 6 ...

  2. R语言画图教程之盒形图

    R语言画图教程之盒形图 我们之前有分享过一系列的R语言画图代码(PCA图.Pathway图.火山图.RDA图.热图),今天再来补充一个盒形图(箱形图)的代码. 以下代码只是示例,不能直接搬来用哦,注意 ...

  3. R语言画图小结

    本文以1950年到2010年期间我国的火灾统计数据为例,数据如下所示: (0)加载数据 data<-read.csv("E:\\MyDocument\\p\\Data\\1950~20 ...

  4. R基本画图

    参考内容:闻博,R语言的绘图功能及应用案例  https://wenku.baidu.com/view/80f22fa50029bd64783e2c22.html R画图是以函数操作为基本的画图模式. ...

  5. R语言画图实例-参考R语言实战

    dose <- c(, , , ,) drugA <- c(, , , , ) drugB <- c(, , , , ) # 数据准备 opar <- par(no.reado ...

  6. R语言画图布局摆放(layout)

    require(ggplot2) require(Cairo) require(grid) p = ggplot(iris,aes(x = Species,y = Sepal.Length,colou ...

  7. R语言画图基础参数设置

    Graphical Parameters You can customize many features of your graphs (fonts, colors, axes, titles) th ...

  8. [R语言画图]气泡图symbols

    绘制气泡图主要使用函数symbols(x,y,circle=r).当中x.y是坐标轴,r是每一个点的半径. x<-rnorm(10) y<-rnorm(10) r<-abs(rnor ...

  9. R语言︱画图

    笔者寄语:不论画啥,你先plot准没错. plot 二维坐标绘图 dotchart 点图 barplot 条形图 hist 直方图 pie 饼图 points 添加点 lines 添加线 text 添 ...

  10. R语言画图

    转http://www.cnblogs.com/jiangmiaomiao/p/6991632.html 0 引言 R支持4种图形类型: base graphics, grid graphics, l ...

随机推荐

  1. centos7部署teleport堡垒机

    Centos7.9部署Teleport堡垒机 简介 Teleport是一款简单易用的开源堡垒机系统,具有小巧.易用的特点,支持 RDP/SSH/SFTP/Telnet 协议的远程连接和审计管理.Tel ...

  2. Git_基础理论

    三个区域 Git本地有三个工作区域:工作目录(Working Directory).暂存区(Stage/Index).资源库(Repository或Git Directory).如果在加上远程的git ...

  3. windows系统,自动设置--shutdown命令了解

    参考:https://baike.baidu.com/item/shutdown/10469108?fr=aladdin 比如你的电脑要在24:00关机,可以选择"开始运行",输入 ...

  4. sql Alias别名

    sql语句中where.group by.having.order by 是否可以使用别名 1.在mysql中,group by.order by中可以使用别名:where中不能使用别名,(如果别名来 ...

  5. Keil Jlink没法找到STM32H750

    https://www.amobbs.com/thread-5713382-1-1.html MDK使用的是5.32,jlink使用的是9.2jlink驱动使用的是6.44b 删除工程下的JLinkS ...

  6. 【Beat】Scrum Meeting 1

    时间:2021年6月26日 1.各个成员今日完成的任务以及贡献小时数 姓名 今日完成任务 贡献小时数 鑫 编写软件的功能测试方案文档,录制视频演示软件系统安装配置过程 4 荣娟 编写软件的功能测试方案 ...

  7. 学习记录--C++多态性简答+编程题

    #include<iostream> #include<string> //双目运算符:运算符作用域两个操作数 //定义一个复数类,重载"+",作为复数类的 ...

  8. python abseil库(app, flags, logging)总结

    absl (Abseil PythonCommon Libraries)(https://abseil.io/docs/python/)是用于构建Python应用程序的Python库代码集合,它包括三 ...

  9. RunnerGo相较于Jmeter优劣势分析

    RunnerGo是一款基于go语言研发的开源测试平台.在这里我想从性能测试方面.结构方面以及功能方面对比两款产品. 性能方面: Runner基于go语言研发,相对于jmeter来说更轻量级.所以性能测 ...

  10. 第一章 1.1.1节 Kubeadm安装K8S高可用集群

    1.1 安装前必读 请不要使用带中文的服务器和克隆的虚拟机. 生产环境建议使用二进制的方式安装. 文档中的IP地址要更换成自己的IP地址,要谨记!!! 1.2 基本环境配置 kubeadm安装方式自1 ...