[R] Strsplit with a separator of ||
jing tang
jing.tang at fimm.fi
Thu Mar 22 08:38:26 CET 2012
Thanks!
JIng
-----Original Message-----
From: Berend Hasselman [mailto:bhh at xs4all.nl]
Sent: 22. maaliskuuta 2012 9:33
To: Berend Hasselman
Cc: jing tang; r-help at r-project.org
Subject: Re: [R] Strsplit with a separator of ||
On 22-03-2012, at 08:28, Berend Hasselman wrote:
>
> On 22-03-2012, at 08:23, jing tang wrote:
>
>> Hi,
>>
>> I tried to use strsplit for separating a string with || like
>> strsplit(string,"\\||") but it returned each single character was
separated.
>>
>> For example:
>>
>> strsplit("a||bc","\\||")
>>
>> [[1]]
>>
>> [1] "a" "" "" "b" "c"
>>
>> where I want the result to be "a" and "bc".
>>
>
> You should escape both \'s.
Of course I should have typed the |'s.
Berend
More information about the R-help
mailing list