Why Isn't the R Function Sink() Writing a Summary Output to My Results File

Why isn't the R function sink() writing a summary output to my results file?

There are as many summary functions as there are regression procedures and many of them use cat with would not get into a value returned. My suggestion is to use cat and capture.output both of which have a file destination parameter and an append option:

cat("Here are my results:\n", file="~/R/res4.txt")
capture.output( summary(res4), file"~/R/res4.txt", append=TRUE)

R: Pander sink stack full when printing summary lm

Actually, if you're just running a standard lm regression, don't pass the summary.lm object to pander, pass the model itself (the lm object)

pander(a.lm)

That should have the information you need. The function calls summary() internally.

sink() won't print output to text file in rmarkdown

I run into a similar issue. One solution of saving the output to local files is to use write.csv() function instead, which also works with non-csv files.

The R code below tries to save output to a file called 'example.txt'.

write.csv(data.frame(data_to_save), file='example.txt')



Related Topics



Leave a reply



Submit