[R] A problem with text manipulation

Bert Gunter gunter.berton at gene.com
Mon Mar 4 20:33:39 CET 2013


Christofer:

This reminds me of those IQ puzzles I took so many years ago as a kid:
Given the numbers 7, 22, 43, 5, 26,...    what are the next 3 numbers
in this series? I don't recall having a clue, and when I got older and
more mathematical, generally came to the conclusion that it could
logically be anything I wanted it to.

Anyway... that's my reaction to your post: I haven't a clue what rule
you used to construct the desired output from the input. But then
others may.  So of course I would not be able to tell you **how** to
write an R procedure that does it. But then others may. If not, I
would suggest that you reveal your secret.

Cheers,
Bert

On Mon, Mar 4, 2013 at 11:13 AM, Christofer Bogaso
<bogaso.christofer at gmail.com> wrote:
> Hello again,
>
> Let say I have following vector:
>
> set.seed(1)
> Vec <- sample(LETTERS[1:5], 10, replace = TRUE)
> Vec
>
> Now with each repeated letter, I like to add suffix programatically.
> Therefore I want to get following vector:
>
> c("B", "B1", "C", "E", "B2", "E1", "E2", "D", "D1", "A")
>
> Can somebody tell me how to achieve that?
>
> 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list