1 安装R
官网:https://www.r-project.org/
Rstudio:https://www.rstudio.com/
2 安装方法
3 Rstudio页面介绍
[图片上传失败...(image-2ca5cd-1621126385078)]
3.1 上手一试
plot是R中的基本画图工具,直接plot(x),参数设置,详见:R---plot()参数详解。
绘制随机数散点图
runif()函数用于生成从0到1区间范围内的服从正态分布的随机数。
plot(rnorm(50))


3.2 上手二试
绘制四分图
boxplot(iris$Sepal.Length~iris$Species,col = c("lightblue","lightyellow","lightpink"))


3.3 设置Rstudio控制台界面字体大小


4 R语言基本操作
4.1 查看和设置工作目录:
getwd()
setwd()
4.2 管理多个R工作目录:
建立New Project:
方法:https://mp.weixin.qq.com/s/G-LXN9P2HVLv9v0cvyFJMA
参考视频:https://m.bilibili.com/video/av25643438.html
4.3 显示文件列表
显示默认路径(工作目录),相当于linux的ls。
dir()


4.4 基本运算法则

4.5 赋值
赋值符号用<-
,这是小于号加上减号,也可以按Alt加上减号
x<- 1+2
,意思是把1+2的运算结果赋值给x。
4.6 删除变量
a<-3
b <- 1
c <- 4
u <- 5+6
rm(b)
rm(u,c)
rm(list = ls()) #清空所有变量
注:R不可以使用中的字符(除了注释外)
4.7 列出历史命令
history()
相当于鼠标单击右上角的history标签,当你双击某个命令,他就会跳到你的控制台大于号后面了,可以修改后运行。
4.8 清空控制台
快捷键:ctrl + L
- 致谢:生信星球@刘小泽@小洁忘了怎么分身
网友评论