From dajohnston at ucdavis.edu  Wed Jul 20 20:14:10 2011
From: dajohnston at ucdavis.edu (David A. Johnston)
Date: Wed, 20 Jul 2011 11:14:10 -0700 (PDT)
Subject: [Rd] apply() returning a list?
In-Reply-To: <D9FF0717-ED0D-4892-8ACF-7D241972370E@comcast.net>
References: <1311118493785-3679619.post@n4.nabble.com>
	<D9FF0717-ED0D-4892-8ACF-7D241972370E@comcast.net>
Message-ID: <1311185650286-3681695.post@n4.nabble.com>

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.  

-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.



[Rd] apply() returning a list?
David A. Johnston