相关疑难解决方法(0)

将A替换为B,B替换为字符串中的A.

我想用R替换所有A's BB's for Aa string.

我的意见是

x = "ABCDBBABDC"
Run Code Online (Sandbox Code Playgroud)

我的输出应该是,

y = "BACDAABADC"
Run Code Online (Sandbox Code Playgroud)

我怎么能在一行中做到这一点?

我试过sub但我不能做多次换人.

regex grep r

11
推荐指数
1
解决办法
165
查看次数

补充DNA序列

假设我有一个DNA序列.我想得到它的补充.我使用了以下代码,但我没有得到它.我究竟做错了什么 ?

s=readline()
ATCTCGGCGCGCATCGCGTACGCTACTAGC
p=unlist(strsplit(s,""))
h=rep("N",nchar(s))
unlist(lapply(p,function(d){
for b in (1:nchar(s)) {    
    if (p[b]=="A") h[b]="T"
    if (p[b]=="T") h[b]="A"
    if (p[b]=="G") h[b]="C"
    if (p[b]=="C") h[b]="G"
}
Run Code Online (Sandbox Code Playgroud)

replace r bioinformatics complement genetics

8
推荐指数
5
解决办法
7028
查看次数

标签 统计

r ×2

bioinformatics ×1

complement ×1

genetics ×1

grep ×1

regex ×1

replace ×1