[R] reverse string

Martyn Byng Martyn.Byng at nag.co.uk
Wed Jul 14 12:31:11 CEST 2010


Hi,

I've no idea if there is a function for doing it, but if not, the
following seems to work

a = "this is a string"
paste(rev(substring(a,1:nchar(a),1:nchar(a))),collapse="")

Martyn
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Trafim Vanishek
Sent: 14 July 2010 11:13
To: r-help at r-project.org
Subject: [R] reverse string

Dear all,

Are there any functions in R to reverse the order of the string.
smth like reverse("abc") to get "cba"?

Thanks a lot.

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}



More information about the R-help mailing list