Re: [R] recoding genetic information using gsub

2014-12-05 Thread William Dunlap
Does the following do what you want? > raw <- c("A/B", " /B", "A/", "/ ") > tmp <- sub("^ */", "./", raw) > cleaned <- sub("/ *$", "/.", tmp) > cleaned [1] "A/B" "./B" "A/." "./." (The " *" is to allow optional spaces before or after the slash.) Bill Dunlap TIBCO Software wdunlap tibco.com On F

Re: [R] recoding genetic information using gsub

2014-12-05 Thread Martin Morgan
On 12/5/2014 11:24 AM, Kate Ignatius wrote: I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/

Re: [R] recoding genetic information using gsub

2014-12-05 Thread Sarah Goslee
Hi, Briefly, you need to read about regular expressions. It's possible to be incredibly specific, and even to do what you want with a single line of code. It's hard to be certain of exactly what you need, though, without a reproducible example. See inline for one possibility. On Fri, Dec 5, 2014

[R] recoding genetic information using gsub

2014-12-05 Thread Kate Ignatius
I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/. C/ C/. G/ G/. T/ T/. / ./. /A ./A /C ./C /G