Another one-liner:
X <- c("abc", "ffd", "sad")
sapply(lapply(strsplit(X, split=""), rev), paste, collapse="")
[1] "cba" "dff" "das"
Khan, Sohail wrote:
Dear List,
I have character vector as follows:
"abc"
"ffd"
"sad"
How can I reverse the string so that
"cba"
"ffd"
"das"
Thanks.
Sohail Khan
Scientific Programmer
COLD SPRING HARBOR LABORATORY
Genome Research Center
500 Sunnyside Boulevard
Woodbury, NY 11797
(516)422-4076
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
|