[R] Editing Strings in R

Gabor Grothendieck ggrothendieck at myway.com
Fri Jul 30 04:08:25 CEST 2004


Bulutoglu Dursun A Civ AFIT/ENC <Dursun.Bulutoglu <at> afit.edu> writes:

> 
> 	I was wondering if there is a way of editting strings in R. I
> have a set of strings and each set is a row of numbers and paranthesis.
> 	For example the first row is: 
> 	(0 2)(3 4)(7 9)(5 9)(1 5)
> 	and I have a thousand or so such rows. I was wondering how I
> could get the corresponding string obtained by adding 1 to all the
> numbers in the string above.

First do the 1 character translations simultaneously using chartr and
then use gsub for the remaining one to two character translation:

gsub("0","10",chartr("0123456789","1234567890","(0 2)(3 4)(7 9)(5 9)(1 5)"))




More information about the R-help mailing list