[R] help with tapply or other apply

2010-05-02 Thread peterko
Hi, my data looks this: id forma program kod obor rocnik 1 10001 kombinovaná Matematika M1101 matematika 1 2 10002 prezenční Informatika N1801 teoretická informatika 1 3 10002 prezenční Informatika

Re: [R] help with tapply or other apply

2010-05-02 Thread Patrick Burns
You don't show how you are doing it with a 'for' loop, but I suspect that you just need to eliminate the subscript you are using for rows. For example: for(i in 1:nrow(data)) { data$z[i] - data[i, 'x'] + data[i, 'y'] } can be written more simply and much more efficiently as: data$z -

Re: [R] help with tapply or other apply

2010-05-02 Thread Jim Lemon
On 05/02/2010 08:26 PM, peterko wrote: Hi, my data looks this: id forma program kod obor rocnik 1 10001 kombinovaná Matematika M1101 matematika 1 2 10002 prezenční Informatika N1801 teoretická informatika 1 3 10002

Re: [R] help with tapply or other apply

2010-05-02 Thread peterko
Thank you Jim, it works very well. I do not need do it using tapply, but i think that it is the way. And Patrick thank you too -- View this message in context: http://r.789695.n4.nabble.com/help-with-tapply-or-other-apply-tp2122683p2122728.html Sent from the R help mailing list archive at

Re: [R] help with tapply or other apply

2010-05-02 Thread Henrique Dallazuanna
Another option could be: data$z - as.numeric(gsub((^\\d{4}).*, \\1, gsub(^$, 2009, data$ukrok))) - data$rocnik On Sun, May 2, 2010 at 8:25 AM, peterko lanikpe...@gmail.com wrote: Thank you Jim, it works very well. I do not need do it using tapply, but i think that it is the way. And