Skip to content
Back to formatted view

Raw Message

Message-ID: <CAM_vjuk9qositfjPQyU-eEsv=cWK7MkQ6kp-vqGbOQ=OJ5nLjA@mail.gmail.com>
Date: 2011-08-03T16:46:35Z
From: Sarah Goslee
Subject: strsplit and forward slash '/'
In-Reply-To: <576B97F0-B443-4F7D-9926-C03BC782C317@imperial.ac.uk>

Hi Federico,

A forward slash isn't a special character:

> strsplit("T/T", "/")
[[1]]
[1] "T" "T"

so there's some other problem.

Are you sure that your first column contains strings and not factors?
What does str(my.data) tell you?

Does
strsplit(as.character(my.data[1,1]), "/")
work?

If you used read.table() to get your data in, you might want the
as.is=TRUE or the stringsAsFactors=FALSE argument.

Sarah

On Wed, Aug 3, 2011 at 12:37 PM, Federico Calboli
<f.calboli at imperial.ac.uk> wrote:
> Hi All,
>
> is there a way of using strsplit with a forward slash '/' as the splitting point?
>
> For data such as:
>
> 1 ? ? ?T/T ? ?C/C ?16/33
> 2 ? ? ?T/T ? ?C/C ?33/36
> 3 ? ? ?T/T ? ?C/C ?16/34
> 4 ? ? ?T/T ? ?C/C ?16/31
> 5 ? ? ?C/C ? ?C/C ?28/29
> 6 ? ? ?T/T ? ?C/C ?16/34
>
> strsplit(my.data[1,1], "/") # and any variation thereof
> Error in strsplit(apoe[1, 1], "/") : non-character argument
>
> Any advice will be gratefully received.
>
> Best wishes,
>
> Federico
>
>


-- 
Sarah Goslee
http://www.sarahgoslee.com