strengejacke / sjPlot

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

How can I view summary statistics? #802

Closed ehsong closed 2 years ago

ehsong commented 2 years ago

I really like this package since I am using MS word, but I can't find a way to obtain a descriptive statistic table or a summary statistics table. Is there a way to print this?

jrcalabrese commented 2 years ago

Hi, would this work for your data? You can create descriptive statistics using psych::describe(), print it using tab_df, and export it as a .doc.

library(tidyverse)
library(sjPlot)
library(psych)

data(airquality)

airquality %>%
  psych::describe() %>%
  tab_df(
    title = "here is my table",
    show.rownames = TRUE,
    file = "~/Documents/mytable.doc")
ehsong commented 2 years ago

@jrcalabrese Thank you! I ended up using gtsummary and flextable to export the table to .doc, but I will try the psych library as well.

strengejacke commented 2 years ago

You could also use sjmisc::descr() and set argument out = "browser", and then copy/paste to word. Or you use datawizard::describe_distribution() and then use print_html() to print to HTML.