Re: [R] Improving effeciency - better table()?

From: Roger D. Peng <rpeng_at_jhsph.edu>
Date: Tue 06 Jul 2004 - 23:00:27 EST

Have you tried using hist() with specifying `br' and `plot = FALSE'? See the note in ?cut.

-roger

Simon Cullen wrote:
> Hi,
>
> I've been running some simulations for a while and the performance of R
> has been great. However, I've recently changed the code to perform a
> sort of chi-square goodness-of-fit test. To get the observed values for
> each cell I've been using table() - specifically I've been using cut2
> from Hmisc to divide up the range into a specified number of cells and
> then using table to count how many observations appear in each cell.
>

>> obs <- table(cut2(z.trun, cuts=breaks))

>
>
> Having done this I've found that the code takes much longer to run - up
> to 10x as long. Is there a more effecient way of doing this? Anyone
> have any thoughts?
>
-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jul 06 23:04:32 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:43 EST