[R] string handling

Hadley Wickham hadley at rice.edu
Fri Jun 4 13:47:33 CEST 2010


On Thu, Jun 3, 2010 at 4:06 PM, Wu Gong <wg2f at mtmail.mtsu.edu> wrote:
>
> 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)

Or with the stringr package:

library(stringr)
str_match(x$var1, "(.)/(.)")

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list