ame2 1 2
#2 str3_name5 3 5
A.K.
- Original Message -
From: Ista Zahn
To: Johannes Radinger
Cc: r-help@r-project.org
Sent: Thursday, September 27, 2012 7:43 AM
Subject: Re: [R] Colsplit, removing parts of a string
Hi Johannes,
On Thu, Sep 27, 2012 at 7:25 AM, Johannes Radinger
Thank you,
this works perfectly...
best regards,
Johannes
On Thu, Sep 27, 2012 at 1:43 PM, Ista Zahn wrote:
> Hi Johannes,
>
> On Thu, Sep 27, 2012 at 7:25 AM, Johannes Radinger
> wrote:
>> Hi,
>>
>> I am using colsplit (package = reshape) to split all strings
>> in a column according to the s
Hello,
By looking at the output of
pat <- "(str)|(_name)|( name)"
strsplit(c("str1_name2", "str3_name5"), pat)
[[1]]
[1] "" "1" "2"
[[2]]
[1] "" "3" "5"
I could understand why colsplit includes NAs as column 'str' values.
So the hack is to fake we want three coluns and then set the first one
Hi Johannes,
On Thu, Sep 27, 2012 at 7:25 AM, Johannes Radinger
wrote:
> Hi,
>
> I am using colsplit (package = reshape) to split all strings
> in a column according to the same patterns. Here
> an example:
>
> library(reshape2)
>
>
> df1 <- data.frame(x=c("str1_name2", "str3_name5"))
> df2 <- da
Hi,
I am using colsplit (package = reshape) to split all strings
in a column according to the same patterns. Here
an example:
library(reshape2)
df1 <- data.frame(x=c("str1_name2", "str3_name5"))
df2 <- data.frame(df1, colsplit(df1$x, pattern = "_", names=c("str","name")))
This is nearly what I
5 matches
Mail list logo