Mercurial > repos > prog > lcmsmatching
comparison hshhlp.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 # Function for testing if a key exists inside a list/hashmap | |
| 2 hHasKey <- function(h, k) { | |
| 3 return(length(which(names(h) == k)) > 0) | |
| 4 } | |
| 5 | |
| 6 # Function for getting a boolean value from a list/hashmap | |
| 7 hGetBool <- function(h, k) { | |
| 8 if (hHasKey(h, k)) return(h[[k]]) else return(FALSE) | |
| 9 } | |
| 10 | |
| 11 # keys A list of keys. | |
| 12 # values A list of values. | |
| 13 # RETURN A hash using keys as keys and values as values. | |
| 14 hCreate <- function(keys, values) { | |
| 15 h <- list() | |
| 16 sz <- min(length(keys), length(values)) | |
| 17 for(i in 1:sz) | |
| 18 h[ keys[[i]] ] <- values[i] | |
| 19 return(h) | |
| 20 } |
