[R] Improving effeciency - better table()?

Simon Cullen cullens at tcd.ie
Tue Jul 6 14:56:14 CEST 2004


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  


Simon Cullen
Room 3030
Dept. Of Economics
Trinity College Dublin

Ph. (608)3477
Email cullens at tcd.ie

More information about the R-help mailing list