Hi,

How about 'capture.output'? 
You could also put the code in a separate file and sink the sourcing it
with the echo=TRUE argument, for example (input.r contains the
commands).

sink("output.txt")
source("input.r", echo=TRUE)
sink()

HTH,

Michal 



*** Note that my e-mail address has changed to [EMAIL PROTECTED]
*** Please update you address books accordingly. Thank you!

_________________________________________
Michal Bojanowski
ICS / Sociology
Utrecht University
Heidelberglaan 2; 3584 CS Utrecht
Room 1428
[EMAIL PROTECTED]
http://www.fss.uu.nl/soc/bojanowski
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cooley, Scott K
Sent: Thursday, March 08, 2007 1:37 AM
To: [email protected]
Subject: [R] sink with R-code

I have the same question that Eusebio had:

Is there a function similar to "sink" that redirect also R code to a
file that
is:

sink("R001")
x <- c(2,-6,-4,8,5,4,1,3,4,-9,0,1)
A <- matrix(x, ncol=3)
A
A.prima <- t(A)
A.prima
dim(A)
dim(A.prima)
sink()

create a file "R001" with contents:

------------------------------------------
     [,1] [,2] [,3]
[1,]    2    5    4
[2,]   -6    4   -9
[3,]   -4    1    0
[4,]    8    3    1
     [,1] [,2] [,3] [,4]
[1,]    2   -6   -4    8
[2,]    5    4    1    3
[3,]    4   -9    0    1
[1] 4 3
[1] 3 4

--------------------------------------------

and what I want is a file with:

--------------------------------------------
> x <- c(2,-6,-4,8,5,4,1,3,4,-9,0,1)
> A <- matrix(x, ncol=3)
> A
     [,1] [,2] [,3]
[1,]    2    5    4
[2,]   -6    4   -9
[3,]   -4    1    0
[4,]    8    3    1
> A.prima <- t(A)
> A.prima
     [,1] [,2] [,3] [,4]
[1,]    2   -6   -4    8
[2,]    5    4    1    3
[3,]    4   -9    0    1
----------------------------------------------
Any hint will be appreciated

Eusebio


Scott K. Cooley
Statistical Sciences, K6-08
Battelle--Pacific Northwest Division
Pacific Northwest National Laboratory
P.O. Box 999
Richland, WA  99352
Phone: 509-375-3604
FAX: 509-375-2604
Email: [EMAIL PROTECTED] 



        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to