How to split a character vector into 3 vectors
This splits them into a 3 column matrix:
x <- c("ASK", "DGH", "ASG", "AUJ", "URT")
library(gsubfn)
z <- strapply(x, ".", simplify = rbind) z
[,1] [,2] [,3] [1,] "A" "S" "K" [2,] "D" "G" "H" [3,] "A" "S" "G" [4,] "A" "U" "J" [5,] "U" "R" "T" z[,1], z[,2] and z[,3] are your vectors.
On Tue, Feb 10, 2009 at 1:50 PM, kayj <kjaja27 at yahoo.com> wrote:
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.