美文网首页生信星球培训第107期
学习小组Day4笔记--大水

学习小组Day4笔记--大水

作者: 大水 | 来源:发表于2021-04-30 00:05 被阅读0次

R语言基础

0.1什么是R语言?

R是用于统计、绘图的语言和操作环境。R是属于GNU系统的一个自由、免费、源代码开放的软件,它是一个用于统计计算和统计制图的优秀工具。
百度百科-R语言

唔,没什么头绪,什么是GNU系统?什么是源代码开放?!!?
唔先硬着头皮跟教程走一下叭

1.1R&R Studio平台的下载

果子学生信 给自己一个全新的R语言环境

1.2尝试一些指令

1.2.1 plot(rnorm(50))

关于plot

嘻嘻嘻,用了老方法,help(plot)
The Default Scatterplot Function
Description
Draw a scatter plot with decorations such as axes and titles in the active graphics window.
Usage
Default S3 method:
plot(x, y = NULL, type = "p", xlim = NULL, ylim = NULL, log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL, ann = par("ann"), axes = TRUE, frame.plot = axes, panel.first = NULL, panel.last = NULL, asp = NA, xgap.axis = NA, ygap.axis = NA, ...)
Arguments
x, y
the x and y arguments provide the x and y coordinates for the plot. Any reasonable way of defining the coordinates is acceptable. See the function xy.coords for details. If supplied separately, they must be of the same length.
type
1-character string giving the type of plot desired. The following values are possible, for details, see plot: "p" for points, "l" for lines, "b" for both points and lines, "c" for empty points joined by lines, "o" for overplotted points and lines, "s" and "S" for stair steps and "h" for histogram-like vertical lines. Finally, "n" does not produce any points or lines.
xlim
the x limits (x1, x2) of the plot. Note that x1 > x2 is allowed and leads to a ‘reversed axis’.
The default value, NULL, indicates that the range of the finite values to be plotted should be used.
ylim
the y limits of the plot.
log
a character string which contains "x" if the x axis is to be logarithmic, "y" if the y axis is to be logarithmic and "xy" or "yx" if both axes are to be logarithmic.
main
a main title for the plot, see also title.
sub
a sub title for the plot.
xlab
a label for the x axis, defaults to a description of x.
ylab
a label for the y axis, defaults to a description of y.
ann
a logical value indicating whether the default annotation (title and x and y axis labels) should appear on the plot.
axes
a logical value indicating whether both axes should be drawn on the plot. Use graphical parameter "xaxt" or "yaxt" to suppress just one of the axes.
frame.plot
a logical indicating whether a box should be drawn around the plot.
panel.first
an ‘expression’ to be evaluated after the plot axes are set up but before any plotting takes place. This can be useful for drawing background grids or scatterplot smooths. Note that this works by lazy evaluation: passing this argument from other plot methods may well not work since it may be evaluated too early.
panel.last
an expression to be evaluated after plotting has taken place but before the axes, title and box are added. See the comments about panel.first.
asp
the y/x aspect ratio, see plot.window.
xgap.axis, ygap.axis
the x/y axis gap factors, passed as gap.axis to the two axis() calls (when axes is true, as per default).
...

关于rnorm
norm是正态分布,前面加r表示生成随机正态分布的序列,其中rnorm(N)表示产生N个数

所以plot(rnorm(50))的意思是生成50个符合正态分布随机数,并做图

boxplot.png

1.2.2 boxplot(iris$Sepal.Length~iris$Species,col = c("lightblue","lightyellow","lightpink"))

虽然不知道是什么意思,不过看结果像是箱图
于是又参考了一下help(boxplot)
并且打印出了鸢尾花数据集iris,如下

    Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
1            5.1         3.5          1.4         0.2     setosa
2            4.9         3.0          1.4         0.2     setosa
3            4.7         3.2          1.3         0.2     setosa
4            4.6         3.1          1.5         0.2     setosa
5            5.0         3.6          1.4         0.2     setosa
6            5.4         3.9          1.7         0.4     setosa
7            4.6         3.4          1.4         0.3     setosa
8            5.0         3.4          1.5         0.2     setosa
9            4.4         2.9          1.4         0.2     setosa
10           4.9         3.1          1.5         0.1     setosa
11           5.4         3.7          1.5         0.2     setosa
12           4.8         3.4          1.6         0.2     setosa
13           4.8         3.0          1.4         0.1     setosa
14           4.3         3.0          1.1         0.1     setosa
15           5.8         4.0          1.2         0.2     setosa
16           5.7         4.4          1.5         0.4     setosa
17           5.4         3.9          1.3         0.4     setosa
18           5.1         3.5          1.4         0.3     setosa
19           5.7         3.8          1.7         0.3     setosa
20           5.1         3.8          1.5         0.3     setosa
21           5.4         3.4          1.7         0.2     setosa
22           5.1         3.7          1.5         0.4     setosa
23           4.6         3.6          1.0         0.2     setosa
24           5.1         3.3          1.7         0.5     setosa
25           4.8         3.4          1.9         0.2     setosa
26           5.0         3.0          1.6         0.2     setosa
27           5.0         3.4          1.6         0.4     setosa
28           5.2         3.5          1.5         0.2     setosa
29           5.2         3.4          1.4         0.2     setosa
30           4.7         3.2          1.6         0.2     setosa
31           4.8         3.1          1.6         0.2     setosa
32           5.4         3.4          1.5         0.4     setosa
33           5.2         4.1          1.5         0.1     setosa
34           5.5         4.2          1.4         0.2     setosa
35           4.9         3.1          1.5         0.2     setosa
36           5.0         3.2          1.2         0.2     setosa
37           5.5         3.5          1.3         0.2     setosa
38           4.9         3.6          1.4         0.1     setosa
39           4.4         3.0          1.3         0.2     setosa
40           5.1         3.4          1.5         0.2     setosa
41           5.0         3.5          1.3         0.3     setosa
42           4.5         2.3          1.3         0.3     setosa
43           4.4         3.2          1.3         0.2     setosa
44           5.0         3.5          1.6         0.6     setosa
45           5.1         3.8          1.9         0.4     setosa
46           4.8         3.0          1.4         0.3     setosa
47           5.1         3.8          1.6         0.2     setosa
48           4.6         3.2          1.4         0.2     setosa
49           5.3         3.7          1.5         0.2     setosa
50           5.0         3.3          1.4         0.2     setosa
51           7.0         3.2          4.7         1.4 versicolor
52           6.4         3.2          4.5         1.5 versicolor
53           6.9         3.1          4.9         1.5 versicolor
54           5.5         2.3          4.0         1.3 versicolor
55           6.5         2.8          4.6         1.5 versicolor
56           5.7         2.8          4.5         1.3 versicolor
57           6.3         3.3          4.7         1.6 versicolor
58           4.9         2.4          3.3         1.0 versicolor
59           6.6         2.9          4.6         1.3 versicolor
60           5.2         2.7          3.9         1.4 versicolor
61           5.0         2.0          3.5         1.0 versicolor
62           5.9         3.0          4.2         1.5 versicolor
63           6.0         2.2          4.0         1.0 versicolor
64           6.1         2.9          4.7         1.4 versicolor
65           5.6         2.9          3.6         1.3 versicolor
66           6.7         3.1          4.4         1.4 versicolor
67           5.6         3.0          4.5         1.5 versicolor
68           5.8         2.7          4.1         1.0 versicolor
69           6.2         2.2          4.5         1.5 versicolor
70           5.6         2.5          3.9         1.1 versicolor
71           5.9         3.2          4.8         1.8 versicolor
72           6.1         2.8          4.0         1.3 versicolor
73           6.3         2.5          4.9         1.5 versicolor
74           6.1         2.8          4.7         1.2 versicolor
75           6.4         2.9          4.3         1.3 versicolor
76           6.6         3.0          4.4         1.4 versicolor
77           6.8         2.8          4.8         1.4 versicolor
78           6.7         3.0          5.0         1.7 versicolor
79           6.0         2.9          4.5         1.5 versicolor
80           5.7         2.6          3.5         1.0 versicolor
81           5.5         2.4          3.8         1.1 versicolor
82           5.5         2.4          3.7         1.0 versicolor
83           5.8         2.7          3.9         1.2 versicolor
84           6.0         2.7          5.1         1.6 versicolor
85           5.4         3.0          4.5         1.5 versicolor
86           6.0         3.4          4.5         1.6 versicolor
87           6.7         3.1          4.7         1.5 versicolor
88           6.3         2.3          4.4         1.3 versicolor
89           5.6         3.0          4.1         1.3 versicolor
90           5.5         2.5          4.0         1.3 versicolor
91           5.5         2.6          4.4         1.2 versicolor
92           6.1         3.0          4.6         1.4 versicolor
93           5.8         2.6          4.0         1.2 versicolor
94           5.0         2.3          3.3         1.0 versicolor
95           5.6         2.7          4.2         1.3 versicolor
96           5.7         3.0          4.2         1.2 versicolor
97           5.7         2.9          4.2         1.3 versicolor
98           6.2         2.9          4.3         1.3 versicolor
99           5.1         2.5          3.0         1.1 versicolor
100          5.7         2.8          4.1         1.3 versicolor
101          6.3         3.3          6.0         2.5  virginica
102          5.8         2.7          5.1         1.9  virginica
103          7.1         3.0          5.9         2.1  virginica
104          6.3         2.9          5.6         1.8  virginica
105          6.5         3.0          5.8         2.2  virginica
106          7.6         3.0          6.6         2.1  virginica
107          4.9         2.5          4.5         1.7  virginica
108          7.3         2.9          6.3         1.8  virginica
109          6.7         2.5          5.8         1.8  virginica
110          7.2         3.6          6.1         2.5  virginica
111          6.5         3.2          5.1         2.0  virginica
112          6.4         2.7          5.3         1.9  virginica
113          6.8         3.0          5.5         2.1  virginica
114          5.7         2.5          5.0         2.0  virginica
115          5.8         2.8          5.1         2.4  virginica
116          6.4         3.2          5.3         2.3  virginica
117          6.5         3.0          5.5         1.8  virginica
118          7.7         3.8          6.7         2.2  virginica
119          7.7         2.6          6.9         2.3  virginica
120          6.0         2.2          5.0         1.5  virginica
121          6.9         3.2          5.7         2.3  virginica
122          5.6         2.8          4.9         2.0  virginica
123          7.7         2.8          6.7         2.0  virginica
124          6.3         2.7          4.9         1.8  virginica
125          6.7         3.3          5.7         2.1  virginica
126          7.2         3.2          6.0         1.8  virginica
127          6.2         2.8          4.8         1.8  virginica
128          6.1         3.0          4.9         1.8  virginica
129          6.4         2.8          5.6         2.1  virginica
130          7.2         3.0          5.8         1.6  virginica
131          7.4         2.8          6.1         1.9  virginica
132          7.9         3.8          6.4         2.0  virginica
133          6.4         2.8          5.6         2.2  virginica
134          6.3         2.8          5.1         1.5  virginica
135          6.1         2.6          5.6         1.4  virginica
136          7.7         3.0          6.1         2.3  virginica
137          6.3         3.4          5.6         2.4  virginica
138          6.4         3.1          5.5         1.8  virginica
139          6.0         3.0          4.8         1.8  virginica
140          6.9         3.1          5.4         2.1  virginica
141          6.7         3.1          5.6         2.4  virginica
142          6.9         3.1          5.1         2.3  virginica
143          5.8         2.7          5.1         1.9  virginica
144          6.8         3.2          5.9         2.3  virginica
145          6.7         3.3          5.7         2.5  virginica
146          6.7         3.0          5.2         2.3  virginica
147          6.3         2.5          5.0         1.9  virginica
148          6.5         3.0          5.2         2.0  virginica
149          6.2         3.4          5.4         2.3  virginica
150          5.9         3.0          5.1         1.8  virginica

大胆猜测一下,用Sepal.Length列的数值,以 Species列的不同种类为分类依据,做出箱图,用亮蓝、亮黄和亮粉以默认颜色给箱图上色【准确性仅为猜测,有待考证


plot(rnorm(50)).png

1.3 用Rproject管理工作目录&显示文件列表

新建并查看.png

1.4 其他一些基础指令

1.4.1 加减乘除

加减乘除.png

1.4.2 赋值

1.4.3 删除变量

赋值并删除.png
ps:教程里咋没有6呢~

1.4.4 列出历史命令

列出历史命令.png

1.4.5 清空控制台

ctrl+l

相关文章

  • 学习小组Day4笔记--大水

    R语言基础 0.1什么是R语言? R是用于统计、绘图的语言和操作环境。R是属于GNU系统的一个自由、免费、源代码开...

  • 2020-05-14

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

  • 学习小组Day4笔记--kan

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

  • 2020-06-18

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

  • 2018-08-30

    学习小组Day4笔记--刘璐这两天在做实验,涉及病例样本采集,经常根据病例时间来调整我的实验时间,昨天作业没有及时...

  • 学习小组day4 笔记(丹)

    嗯,今天的相对简单,很容易接受。可以使用windows的很多快捷键,操作起来不会又生疏感。感谢生信星球

  • 学习小组 Day4 笔记 -- way

    准备工作 查看你的电脑用户中英文名按照方法查阅为英文直接跳过教程上的第二步 下载R和Rstudio按照花花给的教程...

  • 学习小组DAY4 笔记 Diana

    安装R和Rstudio 之前已完成 赋值 <- 删除变量 rm() 列出历史命令 history()

  • 学习小组Day3笔记--大水

    生信届的App Store——Bioconda 今日代码整理 uname -a 查看服务器环境 wget从链接中...

  • 学习小组Day6笔记--大水

    0.0 R包 顾名思义,应该是一个装着什么东西的包裹,包括 代码(不仅仅 是 R 代码!),包及内部函数相关的文档...

网友评论

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

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