sink

R sink(): Error, cannot split the message connection

好久不见. 提交于 2021-02-19 02:59:06
问题 I am trying to log the errors and warnings of an R script into an external file. At the same time I want to be able to see the errors and warnings in the console in RStudio (useful to develop and debug). I am trying to use the following code: logfile <- file("my_file_path", open="wt") sink(logfile, type="message", split = TRUE) But when I try to split the message connection using the funciton sink() I get the following error: Error in sink(logfile, type = "message", split = TRUE) : cannot

Sink is full when calling rmarkdown::render

旧街凉风 提交于 2020-12-03 05:28:14
问题 I'm following this short tutorial to print my R script directly as an HTML document. It should be pretty straightforward. With a few small changes to the header and comments of an otherwise normal R script, calling the command rmarkdown::render('/Users/you/Documents/yourscript.R') at the end of an R script should call the knitr::spin function to go from my R script to an Rmd file to the final HTML or PDF. I'm getting the error: Error in sink(con, split = debug) : sink stack is full and I'm

Sink is full when calling rmarkdown::render

坚强是说给别人听的谎言 提交于 2020-12-03 05:27:13
问题 I'm following this short tutorial to print my R script directly as an HTML document. It should be pretty straightforward. With a few small changes to the header and comments of an otherwise normal R script, calling the command rmarkdown::render('/Users/you/Documents/yourscript.R') at the end of an R script should call the knitr::spin function to go from my R script to an Rmd file to the final HTML or PDF. I'm getting the error: Error in sink(con, split = debug) : sink stack is full and I'm

Sink is full when calling rmarkdown::render

拜拜、爱过 提交于 2020-12-03 05:23:42
问题 I'm following this short tutorial to print my R script directly as an HTML document. It should be pretty straightforward. With a few small changes to the header and comments of an otherwise normal R script, calling the command rmarkdown::render('/Users/you/Documents/yourscript.R') at the end of an R script should call the knitr::spin function to go from my R script to an Rmd file to the final HTML or PDF. I'm getting the error: Error in sink(con, split = debug) : sink stack is full and I'm

How to avoid 'sink stack is full' error when sink() is used to capture messages in foreach loop

江枫思渺然 提交于 2020-05-27 04:26:45
问题 In order to see the console messages output by a function running in a foreach() loop I followed the advice of this guy and added a sink() call like so: library(foreach) library(doMC) cores <- detectCores() registerDoMC(cores) X <- foreach(i=1:100) %dopar%{ sink("./out/log.branchpies.txt", append=TRUE) cat(paste("\n","Starting iteration",i,"\n"), append=TRUE) myFunction(data, argument1="foo", argument2="bar") } However, at iteration 77 I got the error 'sink stack is full'. There are well

R sink() message and output to same file - sanity check

◇◆丶佛笑我妖孽 提交于 2020-01-24 17:38:06
问题 I'm using R's sink() function to capture errors, warnings, messages and console output into a single text file. I'm wondering if simultaneously sinking both message and output types to a single open file is bad to do? I capture all of the above into a single file, but I must open a file handle to allow both sink types to be captured. The following code illustrates using the file handle approach: message_filename = 'script_messages.txt' try(message_file <- file(message_filename, open="at")) #

How to use the `sink` function within another function in R?

大憨熊 提交于 2020-01-14 18:52:16
问题 I have a function fun that relies on an external function external (i.e., from some package). How can I collect all the warnings that come out of external in a character vector? This is a minimal setup: # External function from another package. external <- function() { warning("warning from external...") } # Function meant to capture the warnings. fun <- function() { # Create variable to store the warnings. warns <- vector("character") # Create connection for the sink. connection <-

R function Sink isn't redirecting messages or warnings to a file

不羁岁月 提交于 2020-01-13 11:14:08
问题 I am looking to redirect stderr and stdout messages to an output file. Here's what I tried: sink("outputFile" ,type = c("output", "message")) print("using print") cat("using cat\n") message("using message") warning("using warning") When I run this code, I still see "using message" and "using warning" in my R console, and it's not being redirected. Is there a way to redirect both stdout and stderr to a file? I used this code to redirect my stderr to stdout, but that's not exactly what I'm

Redirect stdout to a txt file in R without the prompt

不想你离开。 提交于 2020-01-06 08:21:25
问题 I know this has been asked before and the answer has always been to use sink but I'm getting the prompt written out too and I don't want that. Any way to just store the output to a .txt file and not the prompts? info(hdr) prints the following to console: > info(hdr) DataFrame with 3 rows and 3 columns Number Type Description <character> <character> <character> NS 1 Integer Number of Samples With Data DP 1 Integer Total Depth DB 0 Flag dbSNP membership, build 131 I want to send all of info()'s

Redirect stdout to a txt file in R without the prompt

扶醉桌前 提交于 2020-01-06 08:21:12
问题 I know this has been asked before and the answer has always been to use sink but I'm getting the prompt written out too and I don't want that. Any way to just store the output to a .txt file and not the prompts? info(hdr) prints the following to console: > info(hdr) DataFrame with 3 rows and 3 columns Number Type Description <character> <character> <character> NS 1 Integer Number of Samples With Data DP 1 Integer Total Depth DB 0 Flag dbSNP membership, build 131 I want to send all of info()'s