I'm new to R programming and I'm trying to write a program for Reverse and Complementary Base. The objective is to design a DNA primer. So I have a DNA sequence with bases A T C G and A complement to T; T=A;C=G;G=C. I figured out how to reverse it already, but for the Complement I can only make it answer for just 1 base but can't be all of the sequence, and I don't know how to combine the reverse and complement functions. Here is my code and I'm totally confused with it. Can someone help me with this problem? You will be my life savior!
strReverse <- function(x)
sapply(lapply(strsplit(x, NULL), rev), paste, collapse="")
strReverse(c("ATCGGTCAATCGA"))
complement.base = function(base){
if(base == 'A' | base == 'a') print("T")
if(base == 'T' | base == 't') print("A")
if(base == 'G' | base == 'g') print("C")
if(base == 'C' | base == 'c') print("G")}
complement.base(base="A")