> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Peng, C
> Sent: Thursday, September 16, 2010 5:39 AM
> To: r-help@r-project.org
> Subject: Re: [R] Problem with cat() == A related question
>
>
>
The question is wehter cat() can print out a matrix as it is. For example,
Let's assume that we have matrices A, B, D(= A+B), if it is possible that
cat("\n", A, "+",B,"=", D, < some control arguments >, "\n")
prints out
matrix A + matrix B = matrix D
where matrices A, B, D (= A+B) should be
> William Revelle
> on Tue, 14 Sep 2010 14:52:32 -0500 writes:
> At 3:45 PM -0400 9/14/10, jim holtman wrote:
>> The problem is the 'cat' enclosing the 'print'; just get rid of the
>> 'cat' -- that is what is causing the extra output
>>
>> On Tue, Sep 14, 2010 at
At 3:45 PM -0400 9/14/10, jim holtman wrote:
The problem is the 'cat' enclosing the 'print'; just get rid of the
'cat' -- that is what is causing the extra output
On Tue, Sep 14, 2010 at 3:34 PM, Peng, C wrote:
It is still visible even it is set invisible(NULL):
fn1 <- function(n = 5){
The problem is the 'cat' enclosing the 'print'; just get rid of the
'cat' -- that is what is causing the extra output
On Tue, Sep 14, 2010 at 3:34 PM, Peng, C wrote:
>
> It is still visible even it is set invisible(NULL):
>
>> fn1 <- function(n = 5){
> + mat <- matrix(rnorm(5*5), 5, 5)
> + ca
It is still visible even it is set invisible(NULL):
> fn1 <- function(n = 5){
+ mat <- matrix(rnorm(5*5), 5, 5)
+ cat(print(mat))
+ invisible(NULL)}
> fn1()
[,1][,2] [,3][,4] [,5]
[1,] -1.22767085 -1.41468587 -2.0156231 0.29732942 0.5755600
[2,]
Try the following:
fn1 <- function(n = 5){
mat <- matrix(rnorm(5*5), 5, 5)
cat(print(mat))
invisible(NULL)}
On Tue, Sep 14, 2010 at 9:59 AM, Peng, C wrote:
>
> Code:
>
>> fn1 <- function(n = 5){
> + mat <- matrix(rnorm(5*5), 5, 5)
> + cat(print(mat))
> + }
>> fn1()
> [,1]
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.
Hello,
If it does not *have* to be cat(), this would work:
fn1 <- function(n = 5){
mat <- matrix(rnorm(5*5), 5, 5)
print(mat)
return(n)
}
Cheers,
Josh
On Tue, Sep 14, 2010 at 4:00 AM, Christofer Bogaso
wrote:
> Dear all, I have a problem with the cat() function. Let say I have following:
>
>
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 -
10 matches
Mail list logo