[R] split character string in matrix into character vector and numeric vector
Kim Milferstedt
milferst at uiuc.edu
Wed May 21 19:11:12 CEST 2008
Hello,
I've got a matrix consisting of one column with n rows. Each field in
the matrix is filled with a character vector.
I would like to convert this matrix into a character vector containing
the B03_MAH-type entries from the beginning of each row and a data.frame
that contains the numeric data, but I am stuck.
I have tried to use textConnection with sep = " " but since there is
sometimes more than two spaces separating the entries, I obtain a result
with columns full of NAs.
Then I tried sub() to replace the all multi-spaces to get only one space
that separates each entry but that didn't work either.
Do you know a good way to convert this matrix?
Thanks already,
Kim
taxa.vec "B03_MAH 0.2115 0.2087 0.2087 0.2147 0.2115 0.2176"
taxa.vec "F02_SSBH 0.2162 0.2191 0.2133 0.2130 0.2220 0.2158"
taxa.vec "G04_MAH 0.2083 0.2111 0.2055 0.2115 0.2140 0.2087"
taxa.vec "A04_MAH 0.2097 0.2126 0.2069 0.2065 0.2097 0.2037"
taxa.vec "E03_MAH 0.2097 0.2069 0.2069 0.2130 0.2155 0.2101"
More information about the R-help
mailing list