[R] Cut off end of string [and some chemotherapy staff]

From: Denis Kazakiewicz <d.kazakiewicz_at_gmail.com>
Date: Sat, 12 Mar 2011 19:31:03 +0200

У Срд, 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


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. Received on Sat 12 Mar 2011 - 19:06:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Mar 2011 - 19:10:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive