Re: [R] strsplit and sapply

2008-04-11 Thread Jonathan Baron
Here is a command I wrote to get the part of the email address before the @ sign. It works, but I don't know why. The variable called email is a vector of email addresses (not yet in character form, so that is why I need "as character"). names(Score) <- sapply(email,function(x) (strsplit(as.cha

Re: [R] strsplit and sapply

2008-04-11 Thread Dimitris Rizopoulos
check this: TEXT <- c("a", "bb;ccc", ";e;ff") SPLIT <- strsplit(TEXT, ";") sapply(SPLIT, "[", 1) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +3

Re: [R] strsplit and sapply

2008-04-11 Thread Henrique Dallazuanna
Try: sapply(strsplit(TEXT, ';'), '[', 1) On Fri, Apr 11, 2008 at 8:12 AM, Dennis Fisher <[EMAIL PROTECTED]> wrote: > Colleagues, > > I have some text: >TEXT<- c("a", "bb;ccc", ";e;ff") > > I want to retrieve the portion of each element before the first > semicolon. I can