Re: [R] reverse string

2010-07-14 Thread Gabor Grothendieck
On Wed, Jul 14, 2010 at 6:13 AM, Trafim Vanishek wrote: > Dear all, > > Are there any functions in R to reverse the order of the string. > smth like reverse("abc") to get "cba"? > Suppose data.frame DF has a column for which we wish to reverse each component. Then using the builtin month.abb try

Re: [R] reverse string

2010-07-14 Thread Petr PIKAL
Hi Quick glance to strsplit help page strReverse <- function(x) sapply(lapply(strsplit(x, NULL), rev), paste, collapse="") Regards Petr r-help-boun...@r-project.org napsal dne 14.07.2010 12:36:12: > On Wed, 2010-07-14 at 12:13 +0200, Trafim Vanishek wrote: > > Dear all, > > > > Are there a

Re: [R] reverse string

2010-07-14 Thread Gavin Simpson
On Wed, 2010-07-14 at 12:13 +0200, Trafim Vanishek wrote: > Dear all, > > Are there any functions in R to reverse the order of the string. > smth like reverse("abc") to get "cba"? > paste(rev(strsplit("abc", split = "")[[1]]), collapse = "") [1] "cba" If your real data is a vector of strings to

Re: [R] reverse string

2010-07-14 Thread Martyn Byng
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-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of