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.

______________________________________________
R-help@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.

Reply via email to