[R] Printing with cat in a procedure

Rui Barradas ruipb@rr@d@@ @ending from @@po@pt
Sat Dec 22 15:39:11 CET 2018


Hello,

Use print(A) and print(C). cat is meant for simpler objects.

Hope this helps,

Rui Barradas

Às 14:31 de 22/12/2018, Steven Yen escreveu:
> How do I print a matrix running a procedure? In the code below, I print
> with the cat command and get a vector (from A and C).
> 
> A<-matrix(rpois(16,lambda=5),nrow=4,byrow=T)
> B<-diag(4)
> 
> try5<-function(A,B){
>    C<-A+B
>    cat("\nA =",A,"\nC = ",C)
> structure(list(A=A,B=B,C=C))
> }
> 
> v<-try5(A,B)
> v$C
>



More information about the R-help mailing list