R- How to return named list without printing to console -


i want return named list function, f. example, calling f(args) gives me named list of variables named x , y. use return(list(x=x,y=y)) @ end of function.

$x [1] 1 2  $y [1] 12 

the problem output above prints values of entire list console. want avoid because $x may take value of large matrix. there way me define model<-f(args) , surpress print out of $x values when type model console. instead, want access x model$x.

use invisible:

f <- function(x, y) {     invisible(list(x, y)) }  f(rnorm(1e4), rnorm(1e4)) ## (nothing)  str(f(rnorm(1e4), rnorm(1e4))) # list of 2 #  $ : num [1:10000] 2.402 0.51 -1.117 0.415 0.849 ... #  $ : num [1:10000] -0.642 0.967 -0.328 -0.33 -0.914 ... 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -