Re: [R] Is this sapply behaviour normal?

From: Kenn Konstabel <lebatsnok_at_gmail.com>
Date: Thu, 26 Jun 2008 15:26:00 +0300

On Thu, Jun 26, 2008 at 12:14 AM, Wacek Kusnierczyk < Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no> wrote:

> >
> >     sapply(dats,function(x){sapply(x,min)})
>
> you can achieve the same with
>
> sapply(dats, sapply, min)
>
>

Did you actually try it?

> dats <- data.frame(1:10,2:11)
> sapply(dats,sapply,min)

      X1.10 X2.11

[1,] 1 2
[2,] 2 3
[3,] 3 4
[4,] 4 5
[5,] 5 6
[6,] 6 7
[7,] 7 8
[8,] 8 9
[9,] 9 10
[10,] 10 11

Sapply doesn't (or can't?) pass arguments to another sapply -- maybe the trick can be done without an anonymous function but not the way you suggested.

Kenn

        [[alternative HTML version deleted]]



R-help_at_r-project.org 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. Received on Thu 26 Jun 2008 - 12:29:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 26 Jun 2008 - 14:31:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive