[R] Problem with cat() == A related question

Peng, C cpeng.usm at gmail.com
Tue Sep 14 15:59:55 CEST 2010


Code:

> fn1 <- function(n = 5){ 
+  mat <- matrix(rnorm(5*5), 5, 5) 
+  cat(print(mat))  
+ } 
> fn1()
           [,1]        [,2]       [,3]        [,4]       [,5]
[1,] -0.7101952  0.78992424 -0.8310871  2.49560703 -0.9543827
[2,] -0.1425682 -2.69186367 -0.5937949  0.03188572 -0.5512154
[3,] -0.3041728  0.05099222 -2.0905322  0.19254519 -0.1208534
[4,]  2.0812597  1.22048195  1.9347253 -1.25478253  1.2998755
[5,]  0.9256113  0.02686392 -0.1059670 -2.62715239 -0.4826737
-0.7101952 -0.1425682 -0.3041728 2.081260 0.9256113 0.7899242 -2.691864
0.05099222 1.220482 0.02686392 -0.8310871 -0.5937949 -2.090532 1.934725
-0.1059670 2.495607 0.03188572 0.1925452 -1.254783 -2.627152 -0.9543827
-0.5512154 -0.1208534 1.299876 -0.4826737> 
> 

Question: Is there any control arguments can be used such that fn1() ONLY
prints out the matrix part?

-- 
View this message in context: http://r.789695.n4.nabble.com/Problem-with-cat-tp2538811p2539017.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list