Rolf Turner wrote:
>
> The answer to your question is ``yeah, sort of''.  The reason for the
> difference is that mean() is generic and has a method for data frames,
> according to which the mean of each column of the data frame is found
> in some ``appropriate'' manner.  (Essentially the columns of the data
> frame must be either numeric or have some sort of date persuasion, else
> you get a warning and an NA for the column in question.  The function
> min()
> is not generic and so if you hit a data frame with min() it (apparently)
> treats that data frame as if it were an atomic vector of data and finds
> the minimum of that atomic vector.  Given, of course, that doing so makes
> sense.
>
> It would seem that you want min() to mimic the behaviour of mean().  To
> achieve this you can, in this instance at least (I think!) simply do
>
>     sapply(dats,function(x){sapply(x,min)})

you can achieve the same with

sapply(dats, sapply, min)

vQ

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to