I would like my lm summary output to be a little more compact than usual. I want to remove some newlines, the "Residuals" section, the line with the word "Coefficients". on the positive side, summary.lm
is written as a native R function, so presumably I can just copy it to a file, change it, and then source it through my .Rprofile
. on the negative side, when I try the first step (copy into emacs and source it), it complains that qr.lm
is not found. is there magic, or am I missing something?
how do I redefine it?
summary.lm <- function(object, correlation = FALSE, symbolic.cor = FALSE,
print.residstable = TRUE, succinct = FALSE, ...)
whatever I will get is not ideal. if someone upstream makes a change in summary.lm, I will have to redo my code. still, in the absence of parameters to control the printing verbosity, I don't know how else to do this.
Indeed, redefining summary.lm
is the way to go for what you want to do.
What you are missing is the concept of namespace in R. summary.lm
is a function from the stats package and so has access to internal functions of this package. Only some functions from a package are exported and available once the package is loaded.
qr.lm
is precisely such an internal function. It is accessible with the triple :::
operator (see ?/
:::``):
> qr.lm
Error: object 'qr.lm' not found
> stats::qr.lm
Error: 'qr.lm' is not an exported object from 'namespace:stats'
> stats:::qr.lm
function (x, ...)
{
if (is.null(r <- x$qr))
stop("lm object does not have a proper 'qr' component.\n Rank zero or should not have used lm(.., qr=FALSE).")
r
}
<bytecode: 0x0000000017983b68>
<environment: namespace:stats>
As you can see, it simply extracts the qr
component of the lm object. You can just paste the code instead of calling the function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With