Skip to content
Prev 58571 / 398502 Next

Resources for optimizing code

On Fri, 5 Nov 2004, Janet Elise Rosenbaum wrote:

            
`S Programming': see the FAQ.
But at the level of the example below, chapter 2 of MASS4 (FAQ again for 
details).
How about DATAFRAME[asst == 1, ] ?

I am not sure if asst has NAs in, but if it has you will get an error from 
                if (asst[i]==1)
and if not, you don't need na.rm=T.
where the subsetting took less than a second for me.

Note that your code converts DATAFRAME to a matrix. If that is reasonable 
(e.g. it is all numeric), then matrix indexing will be faster.