Bioequivalence and Bioavailability Forum

Main page Policy/Terms of Use Abbreviations Latest Posts

 Log-in |  Register |  Search

Back to the forum  Query: 2017-11-23 19:21 CET (UTC+1h)
 
ElMaestro
Hero

Denmark,
2017-09-01 23:23

Posting: # 17760
Views: 618
 

 Beyond sink() - capturing messages to file and stdout [R for BE/BA]

Hi all,

I would like to capture all messages from R (optionally all R input and output) to a file while at the same time having them on stdout as usual.
The sink() function can do either, but apparently (??) not both simultaneously which is what I'd like to use. I have no idea where to start, actually. Note: This involves shelling R under windows so stdout is stdout whether or not it is captured via a pipe into a GUI.
Alternatively, if there were a method assiciated with q() or quit() which would upon termination save all stdout info (messages+input+output; what you see on a console when you interact in e.g. R GUI or R Studio) to a txt-file post hoc then that would be equally good.

Tried google and TFM :PCchaos: Any idea how to do this?

Many thanks and a good weekend to all.

I could be wrong, but…


Best regards,
ElMaestro

No, I still don't believe much in the usefulness of IVIVCs for OIPs when it comes to picking candidate formulations for the next trial. This is not the same as saying I don't believe in IVIVCs.
yjlee168
Senior
Homepage
Kaohsiung, Taiwan,
2017-09-02 05:20

@ ElMaestro
Posting: # 17761
Views: 498
 

 Beyond sink() - capturing messages to file and stdout

Hi ElMaestro,

the meaning of 'stdout'? outputs on the console? If yes, you can try

zz<- file("output.txt",open="wt")
sink(zz,split=TRUE)  ### this will send output to the file and on the console simultaneously
...
sink(zz,split=FALSE)  ### this will send all outputs to the file only, but will not be on the console;default for sink(), same as sink(zz).
sink() ### this will temporarily stop sending output to the file; console output is still on.
sink(zz,split=TRUE) ### re-activate sink() again;
close(zz) ### close the output; use it before q(); otherwise, the output text file may not be complete.

I am not quite sure if I answer your question correctly or not.

All the best,
---Yung-jin Lee
[image]bear v2.8.3:- created by Hsin-ya Lee & Yung-jin Lee
Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear
Download link (updated) -> here
ElMaestro
Hero

Denmark,
2017-09-02 08:10

@ yjlee168
Posting: # 17762
Views: 507
 

 Beyond sink()

Thanks yjlee168,

for trying to help.:-)

I looked at this code already, I believe it is from StackOverflow. It is an example on how to send stdout to a file, and then how to stop doing that so that messages end up on the console again. What I need is both simultaneously and that's how I am of the impression that sink() might not be the solution.
"stdout" is where dos (console) applications, for lack of better terminology, output their stuff. When we open the R GUI or other interface and type a command we are in effect only talking to R's console via a layer of handy windowing which uses stdout and stdin to communicate with R and display to us in a nice windowsy manner what is going on.
If I could save an entire session (with all R's messages) to a file then that would also be great.:confused:

I could be wrong, but…


Best regards,
ElMaestro

No, I still don't believe much in the usefulness of IVIVCs for OIPs when it comes to picking candidate formulations for the next trial. This is not the same as saying I don't believe in IVIVCs.
mittyri
Senior

Russia,
2017-09-02 12:51

@ ElMaestro
Posting: # 17763
Views: 487
 

 TeachingDemos?

Hi ElMaestro,

library(TeachingDemos)
txtStart("temp.txt")
1:10
txtStop()

Is that what you want (from here)?
another solution with sourcing is here

Kind regards,
Mittyri
Back to the forum Activity
 Thread view
Bioequivalence and Bioavailability Forum | Admin contact
17,494 Posts in 3,746 Threads, 1,090 registered users;
30 users online (0 registered, 30 guests).

Cave diving is like playing chess
but the king is not made of wood.    Jochen Hasenmayer

The BIOEQUIVALENCE / BIOAVAILABILITY FORUM is hosted by
BEBAC Ing. Helmut Schütz
XHTML/CSS RSS Feed