Re: [R] splitting character vectors into multiple vectors using strsplit

2012-11-02 Thread arun
PM Subject: Re: [R] splitting character vectors into multiple vectors using strsplit Hi again, I just wanted to thank folks for their suggestions; they led me to understand the *apply family a little better, and to realize the issue was really a question of how to convert a list of equal length vec

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-11-02 Thread R. Michael Weylandt
On Fri, Nov 2, 2012 at 7:49 PM, David Romano wrote: > I don't know if R has the equivalent of an identity > function, but the following solution accomplishes this: > >> splitvectors <- sapply(splitlist, function(x) x) Indeed it does, called, not surprisingly, "identity." You managed to guess the

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-11-02 Thread David Romano
Hi again, I just wanted to thank folks for their suggestions; they led me to understand the *apply family a little better, and to realize the issue was really a question of how to convert a list of equal length vectors into a matrix. In this case sapply only needs to be asked to identify these ve

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread arun
r 7, 2012 2:12 PM Subject: [R] splitting character vectors into multiple vectors using strsplit Hi folks, Suppose I create the character vector charvec by > charvec<-c("a1.b1","a2.b2") > charvec [1] "a1.b1" "a2.b2" and then I use strsplit on charvec a

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread arun
Subject: [R] splitting character vectors into multiple vectors using strsplit Hi folks, Suppose I create the character vector charvec by > charvec<-c("a1.b1","a2.b2") > charvec [1] "a1.b1" "a2.b2" and then I use strsplit on charvec as follows: >

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread Richard M. Heiberger
If you know that there are exactly the same number of items in each string, then something simpler can be constructed. > matrix(unlist(splitlist), length(splitlist[[1]]), length(splitlist)) [,1] [,2] [1,] "a1" "a2" [2,] "b1" "b2" > The rows above are what you are looking for. If you intend

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread Duncan Murdoch
On 07/09/2012 2:12 PM, David Romano wrote: Hi folks, Suppose I create the character vector charvec by > charvec<-c("a1.b1","a2.b2") > charvec [1] "a1.b1" "a2.b2" and then I use strsplit on charvec as follows: > splitlist<-strsplit(charvec,split=".",fixed=TRUE) > splitlist [[1]] [1] "a1" "b1"

[R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread David Romano
Hi folks, Suppose I create the character vector charvec by > charvec<-c("a1.b1","a2.b2") > charvec [1] "a1.b1" "a2.b2" and then I use strsplit on charvec as follows: > splitlist<-strsplit(charvec,split=".",fixed=TRUE) > splitlist [[1]] [1] "a1" "b1" [[2]] [1] "a2" "b2" I was wondering whethe