[Bioc-devel] as.list.List (was Re: parallel package generics)
Martin Morgan
mtmorgan at fhcrc.org
Thu Oct 25 21:34:26 CEST 2012
On 10/25/2012 07:53 PM, Cook, Malcolm wrote:
> Namely, base::Reduce coerces X to a list using as.list if it is an object
> whereas BiocGenerics::Reduce does not. Otherwise they are identical.
>
> As a result, base::Reduce(myGRangesList) fails with "no method for coercing
> this S4 class to a vector".
Well, so when you put it this way... I was wondering why there is no
as.list.List
i.e., an S3 method for List on the generic as.list? This seems to be consistent
with the recommendation on ?Methods under 'Methods for S3 Generic Functions'
(and this little hack seems to allow both Reduce and mclapply to 'work').
Index: NAMESPACE
===================================================================
--- NAMESPACE (revision 70700)
+++ NAMESPACE (working copy)
@@ -332,3 +332,4 @@
expand
)
+S3method(as.list, List)
Index: R/List-class.R
===================================================================
--- R/List-class.R (revision 70700)
+++ R/List-class.R (working copy)
@@ -442,10 +442,11 @@
### Coercion.
###
+as.list.List <-
+ function(x, ...) lapply(x, identity)
+
setAs("List", "list", function(from) as.list(from))
-setMethod("as.list", "List", function(x, ...) lapply(x, identity))
-
setGeneric("as.env", function(x, ...) standardGeneric("as.env"))
setMethod("as.env", "List",
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the Bioc-devel
mailing list