[R] Printing matrix/table in a procedure

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Wed May 15 13:00:35 CEST 2019


Hello,

What's wrong with

test <- function(x){
   table <- matrix(x, nrow = 4)
   cat("\nTable:\n")
   print(table)
   invisible(list(table = table))
}


Hope this helps,

Rui Barradas

Às 10:33 de 15/05/19, Steven Yen escreveu:
> Dear All,
> 
> I would like to get a matrix (table) printed in a procedure, as
> attempted below. Please help. Thanks.
> 
> test<-function(x){
>     table<-matrix(x,nrow=4)
>     cat("\nTable:\n",table)
> invisible(list(table=table))
> }
> 
> x<-1:20
> test(x)
>



More information about the R-help mailing list