I am running regressions in R using lm() function and I can’t manage to display results in simple format. I need to print a vector of p-values:
> summary(lm)$coef[,4]
(Intercept) lun d1un
1.433706e-01 4.673723e-158 6.629044e-04
How can I override scientific notation and get reasonable precision? I tried options(scipen=1000), but it displays endless lines of digits, somehow options(digits=7) does not work here.
I know I can use things like format and sprints, but I would like to set the default display rule for all numeric output, e.g. not more then 6 decimals.
I don’t think this will be possible, for general display throughout R.
?optionssays this about digits:The key phrase is “It is a suggestion only”.
Next, note that what is printed is at first governed by the
print()method applied (this is hidden during interactive use, because R auto-print()s). For details see?printand?print.defaultfor the basic methods. From?print.defaultwe noteand in the Details section we have:
The default for
digitsisNULLwhich indicates thatgetOption("digits")is used, but as we already noted, that is a guide only.There doesn’t appear to be a way to configure R to do what you want nor do it globally. You would need to rewrite
print.default()or all theprint()methods you needed to use and make those version be used instead of the standard versions — not easy now with NAMESPACES.