[R] How to split a character vector into 3 vectors

Simon Pickett simon.pickett at bto.org
Wed Feb 11 10:15:29 CET 2009


someone has probably answered this already but use
substr()
new variable<-substr(old.variable,1,1)

Simon.

----- Original Message ----- 
From: "kayj" <kjaja27 at yahoo.com>
To: <r-help at r-project.org>
Sent: Tuesday, February 10, 2009 6:50 PM
Subject: [R] How to split a character vector into 3 vectors


>
> Hi ,
>
>
> Does any one know how to split a character vector , I have a vector X that
> looks like this and each row has 3 characters
>
>  X
> ASK
> DGH
> ASG
> AUJ
> FRT
>
> I would like to split the vector into 3 vectors that look like this
>
> X1 X2 X3
> A  S K
> D G H
> A S G
> A U J
> U R T
>
> thanks
>
> -- 
> View this message in context: 
> http://www.nabble.com/How-to-split-a-character-vector-into-3-vectors-tp21939492p21939492.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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