所有资料来源于生信技能树


'identical(x,y)#看一下x和y是否一致,包括数据类型、长度是否一致'
'#如果一致,则输出为TRUE,不一致则输出为FALSE'
数据结构也讲完啦
今天晚上讲R package
Rmarkdown(.Rmd)

1. 函数与参数
-
1.1 形式参数与实际参数

-
1.2 写函数的函数


大括号里面是编写函数用的代码

-
1.3 默认参数

2. R package介绍



-
2.1 R包来源及安装
install.packages(“stringr”)#CRAN来源R包安装代码
BiocManager::install(“stringr”)#Bioconductor来源R包安装代码
devtools::install_github(“A/B”)#github来源R包安装代码,A为用户名,B为包名


图片中绿色的地方是下载,下载后放在工作目录,随后进行本地安装
-
2.2 R包加载

library(ggplot)#加载ggplot包
reguire(ggplot)#加载ggplot包
对于一些问题的解决办法
试一试,搜一搜
-
2.3 R包安装前需设置镜像


"设置R包镜像方法2"
options("repos"=c(CRAN="http://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")
-
2.4 R包安装和使用的逻辑
-
(1)安装包-加载包-使用包里的函数
如报错:找不到函数,则加载函数所在的包,重试。
如报错:不存在叫xx名字的包,则安装xx包,重试。
library()#是检查是否安装成功的标准

-
(2)已安装、不加载,直接使用
BiocManager::install()
dplyr::filter()
包名 ::函数名
,表示显式的指定用某个包里的某个函数,通常用于实战中仅用一次的函数,也适用于两个包中的函数名有冲突的情况。

-
2.5 常见疑问
(1)大片提示信息

(2)packages not available


(3)是否更新?
update all/some/none?[a/s/n]:



(4)加载A包,报错B包不存在




(5)报错中有connection或url
切换镜像,检查网络连接。如果都没有问题,运行
options(download.file.method = 'libcurl')
options(url.method='libcurl')
再重新下载。
(6)判断式的安装
if(!require(stringr))install.packages("stringr")
## Loading required package: stringr

-
R语言里的符号



不要那么干,显得很不专业——花花
一定不要太勤快,不然你学不好编程——花花
莫挨老子,不想理你——花花
网友评论