Mercurial > repos > prog > lcmsmatching
view tolst.R @ 5:18254e8d1b72 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 947b8707b06176a4801de64a71c8771617311ffb-dirty
| author | prog |
|---|---|
| date | Thu, 16 Mar 2017 08:15:11 -0400 |
| parents | 3afe41d3e9e7 |
| children |
line wrap: on
line source
################## # OBJECT TO LIST # ################## .object_to_list <- function(obj) { if(is.null(obj)) return(NULL) field_names <- names(obj$getRefClass()$fields()) l <- c() lapply( field_names, function(x) { l<<-c(l,list(obj$field(x))) } ) names(l) <- field_names return(l) } ########### # TO LIST # ########### tolst <- function(v) { switch(typeof(v), S4 = lst <- .object_to_list(v), list = lst <- v, stop("Unknown type '", typeof(v), "'.") ) return(lst) }
