Re: [R] From strings to numbers

2008-05-19 Thread Gabor Grothendieck
On Mon, May 19, 2008 at 7:41 AM, Naira Naouar <[EMAIL PROTECTED]> wrote: > Jim and Chuck, > > Thanks a lot for your replies :) > I knew that there was a better way than the complex thing I was planning to > apply :p (with a lot of for/while/apply arghhh) > I also remembered to use factor when my br

Re: [R] From strings to numbers

2008-05-19 Thread Naira Naouar
Jim and Chuck, Thanks a lot for your replies :) I knew that there was a better way than the complex thing I was planning to apply :p (with a lot of for/while/apply arghhh) I also remembered to use factor when my brain woke up ;) I did something like unclass(factor(c("ab","ab","bb","cat","cat",

Re: [R] From strings to numbers

2008-05-19 Thread Jim Lemon
Naira wrote: Dear all, I would like to know if there is an easy to transform a vector of strings to a vector of integers. Ex: ("ab","ab","bb","cat","cat","ab") will be (1, 1, 2, 3, 3, 1) Hi Naira, It's not all that hard... newfactor<-as.factor(c("ab","ab","bb","cat","cat","ab")) newfactor

Re: [R] From strings to numbers

2008-05-19 Thread Chuck Cleland
On 5/19/2008 6:13 AM, Naira wrote: Dear all, I would like to know if there is an easy to transform a vector of strings to a vector of integers. Ex: ("ab","ab","bb","cat","cat","ab") will be (1, 1, 2, 3, 3, 1) X <- c("ab","ab","bb","cat","cat","ab") as.numeric(as.factor(X)) [1] 1 1 2 3 3 1

[R] From strings to numbers

2008-05-19 Thread Naira
Dear all, I would like to know if there is an easy to transform a vector of strings to a vector of integers. Ex: ("ab","ab","bb","cat","cat","ab") will be (1, 1, 2, 3, 3, 1) Thx, Naira -- View this message in context: http://www.nabble.com/From-strings-to-numbers-tp17315179p17315179.html Sen