Re: [R] separate a variable in several variables

2008-11-13 Thread CE.KA
Thank you DAVID, GABOR, PHIL, WACEK, PETER and GREG I tried: Data2 <- data.frame(x=DATA$x, y = gsub('[^[:digit:]]', '', DATA$x), z= gsub('[^[:alpha:]]', '', DATA$x)) and everything is ok Wacek Kusnierczyk wrote: > > CE.KA wrote: >> >> x >> 1 12F >> 2 13 AD >> 3 356PO >> 4 1D >> 5

Re: [R] separate a variable in several variables

2008-11-12 Thread Gabor Grothendieck
You can fix the space problem by using '[^[:digit:]]' instead of '[[:alpha:]]' and '[^[:alpha:]]' instead of '[[:digit:]]' On Wed, Nov 12, 2008 at 5:10 PM, Peter Alspach <[EMAIL PROTECTED]> wrote: > Tena koe > > Try: > > gsub('[[:alpha:]]', '', unlist(DATA)) and > gsub('[[:digit:]]', '', unlist(DA

Re: [R] separate a variable in several variables

2008-11-12 Thread Wacek Kusnierczyk
CE.KA wrote: > > x > 1 12F > 2 13 AD > 3 356PO > 4 1D > 5 GRT > 6 PO52 > 7 LN4Z > > Is there a way to separarate x in 2 variables: > y: only numeric caracters > z: only alpha caracters > For exemple: > x y z > 1 12F12 F > 2 13 AD 13

Re: [R] separate a variable in several variables

2008-11-12 Thread Peter Alspach
Tena koe Try: gsub('[[:alpha:]]', '', unlist(DATA)) and gsub('[[:digit:]]', '', unlist(DATA)) unlist(DATA) since it looks like DATA maybe a dataframe. You are still left with the spaces, but these can be readily removed. Someone else may offer a better solution. HTH ... Peter Alspach > -