#制作使字母颠倒的function
reverse_myf <- function(string){
a <- strsplit(string,split="")
reversed <- a[[1]][nchar(string):1]
paste(reversed, collapse ="")
}
reverse_myf("how are you?")
#"?uoy era woh"
reverse_myf(reverse_myf("how are you?"))
#"how are you?"
#制作 使句子中 词语顺序颠倒的function
reverse_word <-function(string2){
b<-strsplit(string2,split=" ")
str_length <- length(b[[1]])
reversed2<- b[[1]][str_length:1]
paste(reversed2,collapse = " ")
}
reverse_word("how are you ? , what are you doing ?")
#"? doing you are what , ? you are how"