comparison tolst.R @ 0:e66bb061af06 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
author prog
date Tue, 12 Jul 2016 12:02:37 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e66bb061af06
1 ##################
2 # OBJECT TO LIST #
3 ##################
4
5 .object_to_list <- function(obj) {
6
7 if(is.null(obj))
8 return(NULL)
9
10 field_names <- names(obj$getRefClass()$fields())
11 l <- c()
12 lapply( field_names, function(x) { l<<-c(l,list(obj$field(x))) } )
13 names(l) <- field_names
14 return(l)
15 }
16
17 ###########
18 # TO LIST #
19 ###########
20
21 tolst <- function(v) {
22
23 switch(typeof(v),
24 S4 = lst <- .object_to_list(v),
25 list = lst <- v,
26 stop("Unknown type '", typeof(v), "'.")
27 )
28
29 return(lst)
30 }