Re: [R] nested if/else very slow, more efficient ways?

2006-10-24 Thread Kim Milferstedt
Hi Alex, find below a sample of the input and the desired output of my data. 5a ... 5e are indeed the only possible values for the column in question. I would like to replace 5a -- 1, 55b -- 2, ... 5e -- 5. Kim ## input ### Image_IDClass Max 1 2 3

Re: [R] nested if/else very slow, more efficient ways?

2006-10-24 Thread Stefano Calza
If I get it right (data are not well aligned!) these are values in Class column. Right? Than Class = as.numeric(factor(Class)) should work Stefano On Tue, Oct 24, 2006 at 08:20:08AM -0500, Kim Milferstedt wrote: KimHi Alex, Kim Kimfind below a sample of the input and the desired output of my

Re: [R] nested if/else very slow, more efficient ways?

2006-10-24 Thread Petr Pikal
@stat.math.ethz.ch From: Kim Milferstedt [EMAIL PROTECTED] Subject:Re: [R] nested if/else very slow, more efficient ways? Hi Alex, find below a sample of the input and the desired output of my data. 5a ... 5e are indeed the only possible values for the column in question

[R] nested if/else very slow, more efficient ways?

2006-10-23 Thread Kim Milferstedt
Hello, in the data.frame resultsfuzzy I would like to replace the characters in the second column (5a, 5b, ... 5e) with numbers from 1 to 5. The data.frame has 39150 entries. I seems to work on samples that are nrow(resultsfuzzy) but it takes suspicously long. Do you have any suggestions how

Re: [R] nested if/else very slow, more efficient ways?

2006-10-23 Thread Mike Nielsen
One way that might do what you want is to change the character column to a factor, and then apply as.numeric. resultsfuzzy$x-as.numeric(factor(resultsfuzzy$x,levels=c(5a,5b,5c,5d,5e))) This assumes, of course, that you know that the levels are going to be in the set {5a,5b,5c,5d,5e}. However,

Re: [R] nested if/else very slow, more efficient ways?

2006-10-23 Thread Alex Brown
There are a number of ways this might be approached. Can you please give a sample of your data, and your desired output? Are 5a ... 5e the only values that appear in that column, or are there other values, 4e for instance, that should stay the same during your conversion? Do you wish to use

Re: [R] nested if/else very slow, more efficient ways?

2006-10-23 Thread Duncan Murdoch
On 10/23/2006 6:03 PM, Kim Milferstedt wrote: Hello, in the data.frame resultsfuzzy I would like to replace the characters in the second column (5a, 5b, ... 5e) with numbers from 1 to 5. The data.frame has 39150 entries. I seems to work on samples that are nrow(resultsfuzzy) but it