s-news
[Top] [All Lists]

Re: reversing the order of strings

To: "Khan, Sohail" <khan@cshl.edu>
Subject: Re: reversing the order of strings
From: Chuck Cleland <ccleland@optonline.net>
Date: Fri, 16 Jun 2006 12:43:42 -0400
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <C8696843AE995F4EA4CDC3E2B83482A901879041@mailbox02.cshl.edu>
References: <C8696843AE995F4EA4CDC3E2B83482A901879041@mailbox02.cshl.edu>
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)
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

<Prev in Thread] Current Thread [Next in Thread>