学习小组Day4笔记--axin

作者: axin__ | 来源:发表于2020-05-21 21:40 被阅读0次

R语言基础

安装Rstudio

电脑用户名为英文

Rstudio界面

引自生信星球
引自生信星球

几个命令

  • 散点图
    plot(rnorm(50))

    Rplot
  • 箱式图
    boxplot(iris$Sepal.Length~iris$Species,col = c("lightblue","lightyellow","lightpink"))
    iris$Sepal.Length表示:iris数据框的Sepal.Length这一列数据

    boxplot
  • 显示文件列表
    list.files

  • 删除
    rm(list = ls()) #清空所有变量

  • 列出历史命令
    history()

  • 清空控制台
    ctrl+l

R for data science

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

displ:引擎排量-L 35个,单位为升,小数
hwy:燃油效率:每加仑汽油能跑的公里数(高速路)单位英里/加仑,燃油效率高说明省油。 27个,整数。
class:车型
——生信星球

mpg.png
  • 用不同颜色color的点代表车型class
    ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = class))
    color = class

注:相似语句:
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
注:color="blue"在aes()外

  • 用不同大小size的点代表车型class
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = class))
#> Warning: Using size for a discrete variable is not advised.
size = class

警告:不建议将无序变量种类(class)映射为有序图形属性大小(size)。

  • 用不同透明度alpha的点代表车型class
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, alpha = class))
Warning message:Using alpha for a discrete variable is not advised. 
alpha = class

警告:不建议将无序变量种类(class)映射为有序图形属性透明度(alpha)。

  • 用不同形状shape的点代表车型class
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, shape = class))
Warning messages:
1: The shape palette can deal with a maximum of 6 discrete values because more than 6 becomes difficult to discriminate; you have 7.Consider specifying shapes manually if you must have them. 
2: Removed 62 rows containing missing values (geom_point). 
shape = class

警告:ggplot2 只能同时使用 6 种形状,缺失的62行是suv车型没有被分配到形状
验证62:

 count(mpg,class)
# A tibble: 7 x 2
  class          n
  <chr>      <int>
1 2seater        5
2 compact       47
3 midsize       41
4 minivan       11
5 pickup        33
6 subcompact    35
7 suv           62
  • 手动设置图形属性,所有点设为蓝色
    ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
    color = "blue"

注:color="blue"在aes()外,原因:

此时颜色不会传达关于变量的信息,只是改变图的外观
要想手动设置图形属性,需要按名称进行设置,将其作为几何对象函数的一个参数。这也就是说,需要在函数 aes() 的外部进行设置。
此外,还需要为这个图形属性选择一个有意义的值"blue"。
——R for data science

相关文章

  • 学习小组Day4笔记--axin

    R语言基础 安装Rstudio 电脑用户名为英文 Rstudio界面 几个命令 散点图plot(rnorm(50)...

  • 2020-05-14

    学习小组DAY4笔记-lyq 今天初探R语言 R语言安装 R语言面板在简单了解

  • 学习小组Day2笔记--axin

    一、linux登录 putty远程登录服务器 输入密码时不显示(界面不动没反应),输完了按回车 二、linux命令...

  • 学习小组Day3笔记--axin

    一、linux环境下的软件安装 二、几个操作指令 1.下载 查看服务器是多少位的:uname -a 自动补全cd ...

  • 学习小组Day6笔记--axin

    安装加载dplyr包 注:R包安装命令是install.packages(“包”)或者BiocManager::i...

  • 学习小组Day5笔记--axin

    Tips 显示工作路径 getwd() 查看帮助:?read.table 读取数据X<-read.csv('dou...

  • 学习小组Day7笔记--axin

    参考资料汇总 1.测序过程和原理 原理介绍视频文章《测序的世界》 2.测序类型 生信小白第6天 初涉测序生信小白第...

  • 学习小组Day1笔记--axin

    搜索引擎推荐 首选-谷歌, 其次-必应, 大神级搜索引擎:虫部落搜索 专业教程,推荐使用:搜狗微信、搜狗知乎、简书...

  • 学习小组Day4笔记--kan

    笔记来自生信星球学习小组资料 Day4 学习内容-R语言初上手 1.思维导图镇楼 2.准备工作 安装R与Rstud...

  • 2020-06-18

    学习小组Day4笔记--马小林 1、安装R和Rstudio 中文用户名如何顺利下载 在控制面板里搜索环境变量,然后...

网友评论

    本文标题:学习小组Day4笔记--axin

    本文链接:https://www.haomeiwen.com/subject/ihwzohtx.html