Summary Tables with qwraps2 - How do I export the table?

480 Views Asked by At

I must be missing something really obvious... I'm trying to reproduce the results of the qwraps2 tutorial by Peter DeWitt here I get the console output, but I have no idea how to export the table to make it look like the example.enter image description here

I would like to be able to create "quick and easy" customisable summary tables for publication manuscripts in word and this looks exactly like what I would need.

Thanks a ton for your help.

this is the code I used:

install.packages("qwraps2")  
set.seed(42)
library(qwraps2)
options(qwraps2_markup = 'markdown')

data(mtcars2)
str(mtcars2)

#building summary table
our_summary1 <-
  list("Miles Per Gallon" =
         list("min"       = ~ min(mpg),
              "max"       = ~ max(mpg),
              "mean (sd)" = ~ qwraps2::mean_sd(mpg)),
       "Displacement" =
         list("min"       = ~ min(disp),
              "median"    = ~ median(disp),
              "max"       = ~ max(disp),
              "mean (sd)" = ~ qwraps2::mean_sd(disp)),
       "Weight (1000 lbs)" =
         list("min"       = ~ min(wt),
              "max"       = ~ max(wt),
              "mean (sd)" = ~ qwraps2::mean_sd(wt)),
       "Forward Gears" =
         list("Three" = ~ qwraps2::n_perc0(gear == 3),
              "Four"  = ~ qwraps2::n_perc0(gear == 4),
              "Five"  = ~ qwraps2::n_perc0(gear == 5))
  )

whole <- summary_table(mtcars2, our_summary1)
whole
1

There are 1 best solutions below

0
Peter On

You likely need to have your code in a .Rmd file and code in a knitr chunk. You can see an example of such a file within the qwraps2 package via:

system.file("doc", "summary-statistics.Rmd", package = "qwraps2")