关于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. C++解决海盗分金问题

    #include <iostream> #include <unordered_map> #include <map> // 假定:每个海盗都是一样的聪明,没有谁比 ...

  2. [C++] epoll server实例

    // IO多路复用,事件驱动+非阻塞,实现一个线程完成对多个fd的监控和响应,提升CPU利用率 // epoll优点: // 1.select需要每次调用select时拷贝fd,epoll_ctl拷贝 ...

  3. connect及bind、listen、accept背后的三次握手

    如图所示打上断点,分别找出connect() bind() listen() accpet()对应的函数 源码在上一次作业中已经分析过了 https://www.cnblogs.com/qwertyu ...

  4. jxg项目Day4-数据库和mybatis的连接映射

    配置:yml配置文件中配置数据库的参数,还有映射的参数 1.建实体类User,属性与数据库表对应 2.Mapper包下建UserMapper,继承BaseMapper<User> 3.Se ...

  5. Docker+jenkins 运行 python 自动化

    一.实现思路 在 Linux 服务器安装 docker 创建 jenkins 容器 根据自动化项目依赖包构建 python 镜像(构建自动化 python 环境) 运行新的 python 容器,执行 ...

  6. Servlet的学习之路

    一.什么是什么Servlet? Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客户端的请求和 HTTP 服务器上的数据库或应用程 ...

  7. docker 镜像rabbitmq安装

    docker 镜像rabbitmq安装 1.拉取镜像 带有"mangement"的版本(包含web管理页面): docker pull rabbitmq:3.7.7-managem ...

  8. PHP接受json数据

    PHP接受json数据 获取请求的参数 $input = file_get_contents("php://input"); $input = json_decode($input ...

  9. 在 Kubernetes 集群中部署现代应用的通用模式

    在 Kubernetes 集群中部署现代应用的通用模式 摘要 我们正在经历现代应用交付领域的第二次浪潮,而 Kubernetes 和容器化则是这次浪潮的主要推动力量. 随着第二次浪潮的推进,我们在 N ...

  10. ffmpeg的常用参数

    -encoders 查看支持的编码器 Intel处理器的核心显卡支持的编码器带有qsv后缀(Intel quick sync video acceleration)        NVIDIA独立显卡 ...