Μιχάλης
Μιχάλης

Reputation: 47

Compare the strings of a vector to other strings R

I have a vector with strings as followed dna<-c("ACU","GUA","TCA") and I want to compare those one by one. For example, I want to see if(dna[i] == "ACU") and then proceed to replacing the dna[i] with a single letter like this dna[i] == "L".

Any suggestions? I am really new in R, sorry if this is a stupid question.

Upvotes: 1

Views: 67

Answers (1)

Μιχάλης
Μιχάλης

Reputation: 47

Looks like the answer is this replace(dna,dna=="ACU","L"). Sorry for the trouble. Hope this will help anyone else who has the same question.

Upvotes: 1

Related Questions