[R] disperse variable

Julian Burgos jmburgos at u.washington.edu
Wed Oct 10 21:52:42 CEST 2007


Hi Stefo,

You can use strsplit(), something like this:

strsplit(x,split="_")

You'll get a list with the three vectors.

Julian



Stefo Ratino wrote:
> Hello all,
>    
>   I read the following variable
>   > x
>                 x
> 1  1_A1_ML1_a.DLL
> 2 11_B1_ML2_a.DLL
> 3  4_A1_ML3_a.DLL
> 4 55_C1_ML4_a.DLL
> 5 14_C1_ML5_a.DLL
>    
>   I would like to disperse it in three variable such as
>   > x1
> [1]  1 11  4 55 14
>> x2
> [1] "A1" "B1" "A1" "C1" "C1"
>> x3
> [1] "ML1" "ML2" "ML3" "ML4" "ML5"
> 
>   Are there any function which could enable to do this?
>    
>   Thank you in advance!
>   Stefo
>   
>  
> 
>        
> ---------------------------------
> 
> 	[[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.



More information about the R-help mailing list