donpresente
donpresente

Reputation: 1310

R: Create a txt file with the error handling of tryCatch

I want to know if there is the possibility to create a log with the information of the "error" that force the tryCatch to do "error handling"? Is to be able to gain visibility of potential errors. I want to avoid doing prints. Thanks!

Upvotes: 0

Views: 1742

Answers (1)

Paul
Paul

Reputation: 1355

this will work:

outputFile <-file("output.txt")
tryCatch({
  --- your code ---
}, error = function(e) {
   writeLines(as.character(e), outputFile)
})

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

close(outputFile)

Upvotes: 4

Related Questions