Mercurial > repos > prog > lcmsmatching
view tolst.R @ 1:253d531a0193 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
author | prog |
---|---|
date | Sat, 03 Sep 2016 17:02:01 -0400 |
parents | e66bb061af06 |
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) }