Skip to content

Use {tinytable} to print output from colldiag() #2

@friendly

Description

@friendly

The print.colldiag() output could be greatly enhanced by

  • using background colors to indicate levels of the condition index (CI < 10: lightblue, CI <30: pink, CI > 30: red)
  • background colors for the variance proportions: >0.5: red

How to define a tinytable print method that would work for:

  • console output
  • HTML
  • PDF

Example

> data(cars)
> cars.mod <- lm (mpg ~ cylinder + engine + horse + weight + accel + year,
+                 data=cars)
> cd <- colldiag(cars.mod, center=TRUE) |> prnt()

Console output:

Condition
Index	  -- Variance Decomposition Proportions --
          cylinder engine horse weight accel year 
1   1.000 0.005    0.003  0.005 0.004  0.009 0.010
2   2.252 0.004    0.002  0.000 0.007  0.022 0.787
3   2.515 0.004    0.001  0.002 0.010  0.423 0.142
4   5.660 0.309    0.014  0.306 0.087  0.063 0.005
5   8.342 0.115    0.000  0.654 0.715  0.469 0.052
6  10.818 0.563    0.981  0.032 0.176  0.013 0.004

tinytable does allow to change the background color for complete rows, using something like

tt(x) |> 
  style_tt(i = mpg > 21, background = "lightblue", bold = TRUE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions