[R] Weird Error

Douglas Bates
2004-04-14T22:12:57Z

Bret Collier <bacolli at uark.edu> writes:

> I hope this is not a uniformed question, but I am a little lost.
>
> I ran into a problem this morning and I was wondering if anyone had
> seen it before.  I was trying to summarize each column of a data set
> (150,000 rows, ~50mb, so it was a relatively big file) imported from a text
> file using the below code;
>
> data.summary <- read.csv("c:/summary.txt", sep="")
> data.summary <- as.matrix(data.summary)
> my.summary <- function(x){
>     return(c(min=min(x),max=max(x), mean=mean(x)))}
> apply(data.summary, 2, my.summary)

Peter responded about the error.   You may be able to circumvent the
error by using

apply(data.summary, 2, range)

to get the minimum and maximum and

colMeans(data.summary)

to get the means.  Those are internal functions and will generate less
overhead (and fewer copies) than calls to your own function.