[R] Cut off end of string [and some chemotherapy staff]
Denis Kazakiewicz
d.kazakiewicz at gmail.com
Sat Mar 12 18:31:03 CET 2011
У Срд, 09/03/2011 у 23:29 -0800, Dennis Murphy піша:
> Hi:
>
> Here's one approach, although I imagine there are more efficient ways.
>
> # A function to strip spaces and return the first three non-blank elements
> of a string
> keyset <- function(x) substr(gsub(' ', '', x)[1], 1, 3)
Hello to everybody
How to make a function which would find and cut off last free elements
of a string (including blank elements)?
Thank you in advance
P.S. Chemotherapy studying pitfall (if someone would be interested).
I've recently performed some crazy data transformations to study
chemotherapy cycles. Million thanks to all who helped with advises in
this mail-list (especially to Henrique Dallazuanna :)! So after help of
[R] list my data were looked like
id cycle1 cycle2 cycle3 cycle4 … cyclej
555 ac ac cmf ac NA
After 'aggregate' approach I've got
id regimen NUMcycles
555 ac->cmf 4->1
which is not true (but it turn out that it didn't really matter, because
the majority were treated without such repeats in my study).
This pitfall was not obvious for me (probably because of my ignorance)
and maybe this hint will helpful for somebody who deals with similar
stuff.
However, after 'paste rle' approach I've got something like
id regimen NUMcycles
555 ac->cmf->ac-> 2->1->1->20
where last number in 'NUMcycles' is the number of blanks (some patients
received up to 24 cycles)
That's why I am actually asking a question above
Denis
More information about the R-help
mailing list