[R] Omitting repeated occurrence in a string

Eik Vettorazzi E.Vettorazzi at uke.de
Wed Feb 6 20:48:12 CET 2013

Hi Christopher,
what is the rule to omit "ah" which is also repeated in Text?
The following might be a start:

Text <- "ahsgdvasgAbcabcsdahj"
#finds first repetion of substrings of length 2 or more, here "ah"
#finds all repetions of substrings of length 3 or more, here "Abc"
#finds only subsequent repetions of substrings of length 2 or more


Am 06.02.2013 17:46, schrieb Christofer Bogaso:
> Hello again,
> I was looking for some way on How to delete repeated appearance in a
> String. Let say I have following string:
> Text <- "ahsgdvasgAbcabcsdahj"
> Here you see "Abc" appears twice. But I want to keep only 1
> occurrence. Therefore I need that:
> Text_result <- "ahsgdvasgAbcsdahj" (i.e. the first one).
> Can somebody help me if it is possible using some R function?
> Thanks and regards,
> ______________________________________________
> 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.

Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

More information about the R-help mailing list