strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
606 stars 91 forks source link

Add reference levels to tab_model() #507

Closed roxannebeauclair closed 5 years ago

roxannebeauclair commented 5 years ago

This enhancement request is similar to an issue that has already been reported. However, this request is specifically for the tables and not plots.

It would be nice to have the option for a row for the reference level of factors into models. So in the "Predictors" column you would have the reference level printed first before the other categories. Then in the model output columns you could just have "Ref" printed. This helps the viewers to see what the other terms are being compared to.

strengejacke commented 5 years ago

I have added a show.reflvl-option:

library(sjPlot)
#> #refugeeswelcome
data(iris)
m <- lm(Sepal.Width ~ Petal.Length + Species + Petal.Width, data = iris)
tab_model(m, show.reflvl = TRUE, prefix.labels = "v")
  Sepal.Width
Predictors Estimates CI p
(Intercept) 3.05 2.86 – 3.23 \<0.001
Petal.Length 0.15 0.03 – 0.28 0.018
Petal.Width 0.62 0.36 – 0.89 \<0.001
Species: setosa Reference
Species: versicolor \-1.76 \-2.12 – -1.41 \<0.001
Species: virginica \-2.20 \-2.72 – -1.68 \<0.001
Observations 150
R2 / R2 adjusted 0.551 / 0.539
roxannebeauclair commented 5 years ago

Fantastic! Thanks.

strengejacke commented 5 years ago

Please check if this is sufficient, and if so, just close this issue. Else feel free to make further suggestions.

roxannebeauclair commented 5 years ago

Will do!

On Tue, Jun 25, 2019 at 8:27 AM Daniel notifications@github.com wrote:

Please check if this is sufficient, and if so, just close this issue. Else feel free to make further suggestions.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/strengejacke/sjPlot/issues/507?email_source=notifications&email_token=AA4LMYI47QVKYWTJXGMINOTP4G3ENA5CNFSM4H24IGNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYPFFTQ#issuecomment-505303758, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4LMYIC57XTGFMEWBF5CBDP4G3ENANCNFSM4H24IGNA .

-- Roxanne Beauclair, PhD, MA, MPH Data Yarn www.datayarn.io

The South African Department of Science and Technology / National Research Foundation (DST/NRF) Centre of Excellence in Epidemiological Modelling and Analysis (SACEMA) Stellenbosch University, South Africa www.sacema.com

Cell: +27 82 212 1621 (cell) Skype: roxanne_beauclair