生信入门 第四天

2024-06-10 15:08:36 浏览数 (2)

This is my day 4 homework of BIC by 生信星球.

The content for today is the introduction of R and R studio.

1. Installation of R project and R studio

Watch the tutorial video on bilibli: https://www.bilibili.com/video/BV1J44y1R7ci/?share_source=copy_web&vd_source=ba670d5a7ca081b044384f15866b88ef

All done.

an interesting exaple of r application:

代码语言:R复制
plot(rnorm(50))  
#plot() is a default scatterplot function in r. 
#rnorm() generates n random numbers from a normal distribution with the mean and sd you specify. 

another example:

代码语言:R复制
boxplot(iris$Sepal.Length~iris$Species,col = c("lightblue","lightyellow","lightpink"))

2. Change the appearence

Tools -> Appearence->Global options

3. Basic opereation of R

3.1 Managing working directory

Read a previous paper for this point.

https://mp.weixin.qq.com/s/G-LXN9P2HVLv9v0cvyFJMA

代码语言:R复制
setwd() #设置工作目录
getwd() #查看工作目录

3.2 Show the list of files

代码语言:R复制
> dir()             
> list.files()

3.3 Mathematic calculation

add, minus, multiple, divide, and log (skip).

3.4 create variable

syntax: <-

代码语言:R复制
x <- 1 2

my question is what is the difference between <- and =?

3.5 delete variable

example:

代码语言:R复制
a <- 5 #赋值 a
b <- 18 #赋值b
c <- 26 #赋值c
u <- a   b #赋值u
rm(b)  #删除 b
rm(u,c)  #删除 u,c
rm(list = ls()) #清空所有变量

tips: tab key for filling in the rest of command or file name as far as it can automatically.

3.6 check the history of commands

代码语言:R复制
history()

3.7 clean the console

fast keys:

ctrl l

0 人点赞