# Writes the summary of linear model fits a print output:
xl_renderer.lm <- function(x, options) {
res <- capture.output(summary(x))
res <- paste0(res, collapse = "\n")
class(res) <- "knit_xl_output_vector"
res
}
registerS3method("xl_renderer", "lm", xl_renderer.lm)
# knitxl will now print the summary of `lm` object in the generated
# .xlsx file.
# This will instead write the summary information about the coefficients
# in a table:
xl_renderer.lm <- function(x, options) {
summary(x)$coefficients %>%
as.data.frame() %>%
new_knitxl_output_data_frame()
}
registerS3method("xl_renderer", "lm", xl_renderer.lm)
Run the code above in your browser using DataLab