[R] sink with R-code

Bojanowski, M.J. (Michal) M.J.Bojanowski at uu.nl
Thu Mar 8 15:42:25 CET 2007


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 m.j.bojanowski at uu.nl
*** Please update you address books accordingly. Thank you!

_________________________________________
Michal Bojanowski
ICS / Sociology
Utrecht University
Heidelberglaan 2; 3584 CS Utrecht
Room 1428
m.j.bojanowski at uu.nl
http://www.fss.uu.nl/soc/bojanowski
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Cooley, Scott K
Sent: Thursday, March 08, 2007 1:37 AM
To: r-help at stat.math.ethz.ch
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: scott.cooley at pnl.gov 



	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list