[R] strsplit

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat May 30 15:38:46 CEST 2009



Henrique Dallazuanna wrote:
> Try this:
> 
> unlist(part)[1]
> 
> or
> 
> part[[1]][1]

And in order to isnpect your objects, use

str(part)

at first which tells you about the structure of the object. Then you 
know you got a list and can look up how to extract a part of a list as 
Henrique Dallazuanna ponted out already.

Uwe Ligges


> On Fri, May 29, 2009 at 2:09 PM, Nair, Murlidharan T <mnair at iusb.edu> wrote:
> 
>> I am trying split a string and use one part of it to label graphs. I am
>> using strsplit for that. While I am able to split it, how do I access the
>> separated parts.
>>> filName<-"chrI_2223"
>>> part<- strsplit(filName,"\\_")
>>  > part
>> [[1]]
>> [1] "chrI" "2223"
>>> part[1]
>> [[1]]
>> [1] "chrI" "2223"
>>
>> I looked up the help archive but did not find it. Can someone help me here?
>>
>> Cheers../Murli
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list