From ripley at stats.ox.ac.uk  Thu Jul 21 11:36:33 2011
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 21 Jul 2011 10:36:33 +0100 (BST)
Subject: [Rd] apply() returning a list?
In-Reply-To: <1311185650286-3681695.post@n4.nabble.com>
References: <1311118493785-3679619.post@n4.nabble.com>
	<D9FF0717-ED0D-4892-8ACF-7D241972370E@comcast.net>
	<1311185650286-3681695.post@n4.nabble.com>
Message-ID: <alpine.LFD.2.02.1107211033200.22806@toucan.stats.ox.ac.uk>

On Wed, 20 Jul 2011, David A. Johnston wrote:

> I understand that the coercion to a list is somewhat trivial.  The coercion
> is a little less obvious when apply()'s output is a matrix.  For example,
>
>> x = matrix(1:12, 3, 4)
>> apply(x, 1, range)
>     [,1] [,2] [,3]
> [1,]    1    2    3
> [2,]   10   11   12
>
>> structure(as.list(as.data.frame(apply(x, 1, range))), names = NULL)
> [[1]]
> [1]  1 10
>
> [[2]]
> [1]  2 11
>
> [[3]]
> [1]  3 12
>
>
> Still relatively easy, but I do think it would be logical and intuitive if
> apply() had the same types of arguments as the other similar *apply
> functions.

But you are not the person who would have to maintain the added 
complexity.  There need to be really good arguments for adding code to 
the standard packages (and base in particular): nothing is stopping 
you writing daj_apply() for your own use, and providing you give due 
credit (which many R packages do not for code modified from R) 
distributing it.

>
> -David Johnston
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/apply-returning-a-list-tp3679619p3681695.html
> Sent from the R devel mailing list archive at Nabble.com.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] apply() returning a list?
Prof Brian Ripley