You can use rev function as an example below,
revfun <- function(a) {
b<- a
a=tolower(a)
if ( a==paste(rev(substring(a,1:nchar(a),1:nchar(a))),collapse="")) {
rv<- paste(b, "is a palindrome!")
} else {
rv<- paste(b, "is not a palindrome!")
}
return( rv )
}
x<-"Hello"
revfun(x)
revfun("anna")
revfun("Anna")