[R] Problem with cat()
Christofer Bogaso
bogaso.christofer at gmail.com
Tue Sep 14 13:00:46 CEST 2010
Dear all, I have a problem with the cat() function. Let say I have following:
fn1 <- function(n = 5){
mat <- matrix(rnorm(5*5), 5, 5)
cat(as.character(mat))
return(n)
}
However when I run above function I get this:
> fn1()
-0.601930631438248 -1.16950049447942 0.469257329394626
-1.39766868242906 -1.02580943892082 1.4067931110327 -1.07245318857022
-0.0205043699310245 0.234628727206755 2.20623115088835
0.689246510169205 0.390165590650482 1.16264636627546 -1.26460050014308
-0.0618394808642369 1.55065748588694 -1.09179651631271
1.77868450520847 1.56281762714862 -0.0428547138289468 -1.5041448417776
0.221592557337622 -1.91535929883353 -0.712994991755814
-0.440738636680476[1] 5
How can I preserve the "matrix" format while printing?
Thanks,
More information about the R-help
mailing list