printCoefmat
Print Coefficient Matrices
Utility function to be used in higher-level print
methods, such as those for summary.lm
,
summary.glm
and anova
. The
goal is to provide a flexible interface with smart defaults such
that often, only x
needs to be specified.
- Keywords
Usage
printCoefmat(x, digits = max(3, getOption("digits") - 2),
signif.stars = getOption("show.signif.stars"),
signif.legend = signif.stars,
dig.tst = max(1, min(5, digits - 1)),
cs.ind = 1L:k, tst.ind = k + 1L,
zap.ind = integer(), P.values = NULL,
has.Pvalue = nc >= 4L && length(cn <- colnames(x)) &&
substr(cn[nc], 1L, 3L) %in% c("Pr(", "p-v"),
eps.Pvalue = .Machine$double.eps,
na.print = "NA", quote = FALSE, right = TRUE, …)
Arguments
- x
a numeric matrix like object, to be printed.
- digits
minimum number of significant digits to be used for most numbers.
- signif.stars
logical; if
TRUE
, P-values are additionally encoded visually as ‘significance stars’ in order to help scanning of long coefficient tables. It defaults to theshow.signif.stars
slot ofoptions
.- signif.legend
logical; if
TRUE
, a legend for the ‘significance stars’ is printed providedsignif.stars = TRUE
.- dig.tst
minimum number of significant digits for the test statistics, see
tst.ind
.- cs.ind
indices (integer) of column numbers which are (like) coefficients and standard errors to be formatted together.
- tst.ind
indices (integer) of column numbers for test statistics.
- zap.ind
indices (integer) of column numbers which should be formatted by
zapsmall
, i.e., by ‘zapping’ values close to 0.- P.values
logical or
NULL
; ifTRUE
, the last column ofx
is formatted byformat.pval
as P values. IfP.values = NULL
, the default, it is set toTRUE
only ifoptions("show.coef.Pvalue")
isTRUE
andx
has at least 4 columns and the last column name ofx
starts with"Pr("
.- has.Pvalue
logical; if
TRUE
, the last column ofx
contains P values; in that case, it is printed if and only ifP.values
(above) is true.- eps.Pvalue
number, ..
- na.print
a character string to code
NA
values in printed output.- quote, right, …
further arguments passed to
print.default
.
Value
Invisibly returns its argument, x
.
See Also
Examples
library(stats)
# NOT RUN {
cmat <- cbind(rnorm(3, 10), sqrt(rchisq(3, 12)))
cmat <- cbind(cmat, cmat[, 1]/cmat[, 2])
cmat <- cbind(cmat, 2*pnorm(-cmat[, 3]))
colnames(cmat) <- c("Estimate", "Std.Err", "Z value", "Pr(>z)")
printCoefmat(cmat[, 1:3])
printCoefmat(cmat)
op <- options(show.coef.Pvalues = FALSE)
printCoefmat(cmat, digits = 2)
printCoefmat(cmat, digits = 2, P.values = TRUE)
options(op) # restore
# }