returned objects within a list while keeping the original data structure in R -
in r, need return 2 objects function:
myfunction() { a.data.frame <- read.csv(file = input.file, header = true, sep = ",", dec = ".") index.hash <- get_indices_function(colnames(a.data.frame)) alist <- list("a.data.frame" = a.data.frame, "index.hash" = index.hash) return(alist) }
but, returned objects myfunction become list not data.frame , hash.
any appreciated.
you can return 1 object r function; consistent with..pretty every other language i've used. however, you'll note objects retain original structure within list - alist[[1]] , alist[[2]] should data frame , hash respectively, , structured as data frames , hashes. once you've returned them function, can split them out unique objects if want :).
Comments
Post a Comment