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
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
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
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
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:
>
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
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"
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
8 matches
Mail list logo