[R] string handling

Wu Gong wg2f at mtmail.mtsu.edu
Thu Jun 3 23:06:45 CEST 2010


Hope it helps.

text <- "var1        var2
9G/G09    abd89C/T90
10A/T9    32C/C
90G/G      A/A"

x <- read.table(textConnection(text), header = T)

x$var1.1 <- sub(".*(.)/.*", "\\1", x$var1)
x$var1.2 <- sub(".*/(.).*", "\\1", x$var1)
x$var2.1 <- sub(".*(.)/.*", "\\1", x$var2)
x$var2.2 <- sub(".*/(.).*", "\\1", x$var2)

-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/string-handling-tp2242119p2242357.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list