读取xlsx文件
install.packages("openxlsx")
library(openxlsx)
data<- read.xlsx("Lipstick.xlsx")
批量替换
install.packages("do")
library(do)
Replace(data=data,from="xxx",to=1)#将xxx替换为1,如果删除xxx,to=""
Replace(data=data,from=c("xxx","xxxx"),to=1)#将xxx与xxxx都替换为1,如果删除,to=""
#批量替换应用
> lib1 <- Replace(data = lib1,pattern = c("NC_001133.9:chr01","NC_001134.8:chr02","NC_001135.5:chr03","NC_001136.10:chr04","NC_001137.3:chr05","NC_001138.5:chr06","NC_001139.9:chr07","NC_001140.6:chr08","NC_001141.2:chr09","NC_001142.9:chr10","NC_001143.9:chr11","NC_001144.5:chr12","NC_001145.3:chr13","NC_001146.8:chr14","NC_001147.6:chr15","NC_001148.4:chr16"))
filter_lib <- Replace(data=lib1,from = "TACGACGACTCACTATAGCGCGTCTCAGATC",to='')
uniqsequence_lib1 <- Replace(data=filter_lib,from = "TTTCGAGACGGCTAGTTAATGCTCACGGGC",to='')
参考文章:https://blog.csdn.net/weixin_44286888/article/details/121636122
https://blog.csdn.net/weixin_39946964/article/details/111609477?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_default&utm_relevant_index=5