Ronen--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
What exactly is the problem?Long runtime? Crashing? Opaque code?
On Wed, Aug 27, 2014 at 10:11 AM, ronen <rfl...@gmail.com> wrote:
I have a big data baseI want to do the following partial sums:X=matrix(1:64,8,8)y=rep(1:2,c(4,4))psum=by(X,y,apply,2,sum)print(psum)Is there a better/quicker way to do it?Thank you
Ronen--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
(a) Readability could be improved. Recall that future-self will have to understand the code. I would loop over categories of y as you will lose nothing in efficiency (by() simply wraps around tapply() which is nothing but a loop), but will gain on readability.(b) I think that rowSums and colSums are slightly more efficiency that apply(X,2,sum).(c) The dplyr package is super efficient for data manipulations. You might get good performance by compounding dplyr::group_by and dplyr::summarise. It is actually a package worth knowing anyhow....
On Wed, Aug 27, 2014 at 11:20 AM, ronen <rfl...@gmail.com> wrote:
no problem just wondered if this is how it should be doneto optimize my workThank you!
On Wednesday, August 27, 2014 10:44:42 AM UTC+3, Jonathan Rosenblatt wrote:
What exactly is the problem?Long runtime? Crashing? Opaque code?
On Wed, Aug 27, 2014 at 10:11 AM, ronen <rfl...@gmail.com> wrote:
I have a big data baseI want to do the following partial sums:X=matrix(1:64,8,8)y=rep(1:2,c(4,4))psum=by(X,y,apply,2,sum)print(psum)Is there a better/quicker way to do it?Thank you
Ronen--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsubscribe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.