Re: [R] Mapping factors to a new set of factors

2009-09-11 Thread james.arnold
Thanks Jorge, That is what I was looking for. Cheers, James From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] Sent: 08 September 2009 18:41 To: Arnold, James Cc: r-help@r-project.org Subject: Re: [R] Mapping factors to a new set of factors Hi James, Take a look at the "recode" function

Re: [R] Mapping factors to a new set of factors

2009-09-11 Thread james.arnold
Thanks a lot Phil, Recode is exactly what I was looking for. I managed to get my old function working using sapply, but the performance was horrendously slow! One other thing was that the lvls vector can only seem to be set within the global scope of R, and local variables within a function do

Re: [R] Mapping factors to a new set of factors

2009-09-11 Thread james.arnold
Thanks Jim, I managed to get my function to work by putting it within an sapply. Unfortunately the performance was terrible, so I've gone with the suggestion of other posters to use recode in the car package. Cheers, James -Original Message- From: jim holtman [mailto:jholt...@gmail.com

[R] Mapping factors to a new set of factors

2009-09-08 Thread james.arnold
Hello, I am trying to map a factor variable within a data frame to a new variable whose entries are derived from the content of the original variable and there are fewer factors in the new variable. That is, I'm trying to set up a surjection. After first thinking that this would be a common op