[R] Printing with cat in a procedure

Jeff Newmiller jdnewmil @ending from dcn@d@vi@@c@@u@
Sat Dec 22 15:49:05 CET 2018


Try using print instead of cat [1], and please read about what the arguments are in the help file [2][3] for any function you are using before posting a question.

[1] https://stackoverflow.com/questions/31843662/what-is-the-difference-between-cat-and-print
[2] ?cat
[3] ?print

On December 22, 2018 6:31:52 AM PST, Steven Yen <styen using ntu.edu.tw> wrote:
>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

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list