I want to source a file and redirect to print the errors in a variable. I tried the next code which i found in this url In R, is it possible to redirect console output to a variable? but without success...
here is the example i run:
out<-vector("character")
con<- textConnection('out', 'wr')
sink(con)
source('some_file.R', encoding = 'UTF-8') #failed capturing
sink()
close(con)
I also found this -> 4.3. Redirecting Output to a File but also without success...
here is the example i run:
sink("script_output.txt") # Redirect output to file
source("script.R") # Run the script, capturing its output
sink() # Resume writing output to console
I don't have idea why it's not working. Where is the wrong?
If the tags or the question is not "complete" feel free to change it.