s-news
[Top] [All Lists]

Re: reversing the order of strings

To: "Chuck Cleland" <ccleland@optonline.net>
Subject: Re: reversing the order of strings
From: "Khan, Sohail" <khan@cshl.edu>
Date: Fri, 16 Jun 2006 13:00:51 -0400
Cc: <s-news@lists.biostat.wustl.edu>
Thread-index: AcaRZMOY1UO7ItvxStKLGhaEfLSstgAAYhSA
Thread-topic: [S] reversing the order of strings
Thank you all, for your one liners!!

-Sohail

-----Original Message-----
From: Chuck Cleland [mailto:ccleland@optonline.net]
Sent: Friday, June 16, 2006 12:48 PM
To: Khan, Sohail
Cc: s-news@lists.biostat.wustl.edu
Subject: Re: [S] reversing the order of strings


Sorry, strsplit() is only in R.

Chuck Cleland wrote:
> 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>