Week 4

Robert W. Walker

Overview

  1. AMA
  2. Quarto Things
  3. On Tables

The Assignment for this week

Finish the portfolio cleaning up and polishing for last time and add one more post. A table. Actually two.

  1. A gt or flextable
  2. A datatable

More on those tools in the second half of class.

AMA

If there are things you want to figure out with quarto, what are they?

  • One of your classmates investigated comments. Perhaps they wish to share?

A Flag Change and a Difference Between Quarto and RMarkdown

embed-resources

Inline Code?

  1. Do we know how to construct inline code?

You can write smart text using inline code. In this, I used the package fontawesome to insert the icons.

fa-icons and inline

The Structure of a Quarto Website

This comes from the example on my github page

  1. The project

Project YAML These are covered under Project

The Structure of a Quarto Website

This comes from the example on my github page

  1. The website

website

These are covered in website

The Structure of a Quarto Website

This comes from the example on my github page

  1. The website
    • The navbar

navbar

The details can be found in that section of the documents.

The Structure of a Quarto Website

This comes from the example on my github page

  1. The website
    • The navbar
      • The navbar-items

navbar-items

The details can be found in that section of the documents.

Other Website Features

  1. Search

  2. Social

  3. Comments

Listings

The details on Listing

A Feed

Enabling an RSS feed

The About page

All about About

The format

Options to carryover for all documents. It is worth noting you can add to these or override them in individual posts.

My html format

This follows from the html formatting

Quarto things

  • The Amazing Quarto thread

Some General Comments on your Portfolios

Code folding:

Fold

Default Theming

NEVER USE DEFAULT THEMES

  1. They’re ugly.
  2. It makes people wonder if you understand theming.

A blog post

theme_set(theme_minimal())

On Tables

  1. datatable from DT
  2. For mocking up model results, stargazer
  3. flextable
  4. gt

datatable is amazing

datatable from the DT library is a port of a Javascript library. It enables some very neat features.

A datatable

Loading the Data

Code
library(tidyverse)
library(DT)
Bonds <- read.csv(url("https://raw.githubusercontent.com/robertwwalker/DADMStuff/master/BondFunds.csv"))
Bonds %>%
    mutate(Risk = as.factor(Risk), Fees = as.factor(Fees), Type = as.factor(Type)) %>%
    datatable(filter = "top", options = list(pageLength = 10, autoWidth = TRUE))

Loading the Data

Details

filter details

Editing?

Code
datatable(head(Bonds), caption = htmltools::tags$caption(style = "caption-side: bottom; text-align: center;",
    htmltools::strong("Table 2: Editable Bonds Data")), options = list(pageLength = 5),
    editable = "cell")

Extras

Other elements can be incorporated into datatable via extensions. You can find the set of extensions here.. Let me combine the last one with the previous datatable of the full data to show one possibility.

Editing and Saving?

Code
datatable(Bonds, filter = "top", caption = htmltools::tags$caption(style = "caption-side: bottom; text-align: center;",
    htmltools::strong("Table 2: Editable Bonds Data")), editable = "cell", extensions = c("Scroller",
    "Buttons"), options = list(deferRender = TRUE, scrollY = 400, scroller = TRUE,
    dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print")))

The resultant csv

Editing the first three rows of the datatable and clicking .csv yields:

Combining this with reactives has promise

gt

An Example

Borrowed from Ted Laderas.

Code
items <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-05-05/items.csv")
datatable(head(items))

A clever function

Code
library(ggimage)
library(gt)
most_expensive <- function(category_name = NULL, price_category = buy_value) {

    if (!is.null(category_name)) {
        items <- items %>%
            filter(category == category_name)
    }
    items %>%
        top_n(10, {
            {
                price_category
            }
        }) %>%
        arrange(desc({
            {
                price_category
            }
        })) %>%
        select(name, image = image_url, sell_value, buy_value, category) %>%
        gt() %>%
        text_transform(locations = cells_body(vars(image)), fn = function(x) {
            web_image(url = x, height = 50)
        })

}

Making a Table {.smaller} with a Spanner

Code
most_expensive() %>%
    tab_header(title = "Most Expensive Items in Animal Crossing By Buy Price") %>%
    cols_label(name = "Item", sell_value = "Sale Price", buy_value = "Buy Price",
        category = "Item Type", image = "Picture") %>%
    tab_spanner(label = "Prices", columns = c(buy_value, sell_value))
Most Expensive Items in Animal Crossing By Buy Price
Item Picture Prices Item Type
Buy Price Sale Price
Royal Crown 1200000 300000 Hats
Crown 1000000 250000 Hats
Gold Armor 320000 80000 Dresses
Golden Casket 320000 80000 Furniture
Grand Piano 260000 65000 Furniture
Golden Toilet 240000 60000 Furniture
Blue Steel Staircase 228000 NA Furniture
Iron Bridge 228000 NA Furniture
Red Steel Staircase 228000 NA Furniture
Red Zen Bridge 228000 NA Furniture
Zen Bridge 228000 NA Furniture

Delimited Spanners are Neat

With renamed or well designed data naming conventions, this is a very neat trick.

The help on delimited spanners

Bonds %>%
    mutate(`Fund Number` = Fund.Number, `Expense Ratio` = Expense.Ratio, `Return.3-Year` = X3.Year.Return,
        `Return.5-Year` = X5.Year.Return) %>%
    select(-c(Fund.Number, Expense.Ratio, X3.Year.Return, X5.Year.Return)) %>%
    relocate(c(Return.2009, `Return.3-Year`, `Return.5-Year`), .after = last_col()) %>%
    group_by(Risk) %>%
    gt() %>%
    tab_spanner_delim(delim = ".")

Bonds: Grouped and Delimit Tabbed

Fund Number Type Assets Fees Expense Ratio Return
2009 3-Year 5-Year
Below average
FN-1 Intermediate Government 7268.1 No 0.45 6.9 6.9 5.5
FN-2 Intermediate Government 475.1 No 0.50 9.8 7.5 6.1
FN-8 Intermediate Government 2188.8 No 0.55 7.4 6.4 5.2
FN-9 Intermediate Government 390.6 No 0.67 5.3 6.1 5.0
FN-10 Intermediate Government 544.1 No 0.63 5.7 6.2 5.1
FN-12 Intermediate Government 155.5 No 0.91 12.4 6.4 5.1
FN-13 Intermediate Government 397.5 No 0.60 6.0 6.3 5.1
FN-14 Intermediate Government 906.1 No 0.51 8.1 6.1 5.1
FN-15 Intermediate Government 379.1 No 0.57 5.7 6.6 5.2
FN-17 Intermediate Government 1539.1 No 0.66 6.4 6.2 5.0
FN-18 Intermediate Government 167.3 No 0.60 5.8 6.2 5.1
FN-19 Intermediate Government 448.0 No 0.77 10.1 6.5 5.3
FN-20 Intermediate Government 238.1 No 1.13 4.4 5.5 4.3
FN-21 Intermediate Government 557.8 No 0.74 9.0 6.0 4.9
FN-23 Intermediate Government 261.8 Yes 1.08 3.5 5.1 4.0
FN-28 Intermediate Government 291.1 Yes 1.10 5.1 5.8 4.6
FN-29 Intermediate Government 6332.5 Yes 0.73 4.8 6.0 4.9
FN-38 Intermediate Government 135.9 No 0.47 13.0 5.1 4.5
FN-48 Intermediate Government 588.6 Yes 0.96 6.2 5.1 4.4
FN-50 Intermediate Government 84.9 No 0.71 11.2 3.9 3.7
FN-55 Intermediate Government 1133.3 No 0.46 3.4 2.3 2.5
FN-58 Intermediate Government 425.6 Yes 0.97 9.1 4.7 4.1
FN-76 Intermediate Government 285.5 No 0.36 7.1 5.5 4.8
FN-81 Intermediate Government 595.1 No 0.55 5.5 6.3 5.2
FN-84 Intermediate Government 686.6 Yes 0.94 7.2 3.7 3.5
FN-87 Intermediate Government 33.0 No 1.00 0.2 6.1 4.8
FN-88 Short Term Corporate 139.1 No 0.51 5.5 5.1 4.3
FN-89 Short Term Corporate 123.9 No 0.32 5.0 4.4 4.1
FN-91 Short Term Corporate 203.4 Yes 1.00 8.3 5.2 4.4
FN-92 Short Term Corporate 66.1 No 0.71 6.8 4.9 4.0
FN-93 Short Term Corporate 1346.0 No 0.65 8.6 6.1 4.8
FN-94 Short Term Corporate 4772.9 No 0.56 5.0 4.9 4.2
FN-95 Short Term Corporate 77.5 No 0.51 2.2 3.7 3.5
FN-96 Short Term Corporate 76.2 No 0.68 2.5 5.2 4.2
FN-99 Short Term Corporate 96.1 No 0.73 7.3 4.8 4.1
FN-100 Short Term Corporate 226.8 No 0.45 2.9 3.6 3.6
FN-104 Short Term Corporate 36.5 No 0.76 5.5 5.0 4.0
FN-105 Short Term Corporate 127.4 No 0.45 3.6 3.3 3.3
FN-111 Short Term Corporate 177.8 Yes 0.94 8.2 5.4 4.4
FN-118 Short Term Corporate 135.4 No 0.70 6.8 4.2 3.7
FN-119 Short Term Corporate 388.0 No 0.56 6.7 4.6 3.8
FN-120 Short Term Corporate 18.6 No 0.89 4.1 3.4 3.1
FN-123 Short Term Corporate 159.9 Yes 0.80 5.9 4.8 4.0
FN-125 Short Term Corporate 42.6 No 0.74 5.4 4.6 4.0
FN-126 Short Term Corporate 111.4 No 0.97 9.1 4.5 3.7
FN-127 Short Term Corporate 114.5 No 0.65 9.5 4.9 4.1
FN-129 Short Term Corporate 17.4 No 0.75 2.8 3.9 3.4
FN-131 Short Term Corporate 262.5 No 0.85 9.5 4.4 3.9
FN-135 Short Term Corporate 49.9 No 0.60 1.6 1.3 2.3
FN-136 Short Term Corporate 640.3 No 0.54 7.0 2.3 2.7
FN-139 Short Term Corporate 36.8 No 0.38 3.6 1.7 2.5
FN-140 Short Term Corporate 145.4 Yes 0.90 10.1 3.1 3.0
FN-150 Short Term Corporate 69.0 Yes 0.98 5.2 4.7 3.4
FN-161 Short Term Corporate 478.4 No 0.64 6.8 2.2 2.4
FN-166 Short Term Corporate 6981.5 No 0.45 7.3 1.7 2.4
FN-175 Short Term Corporate 95.4 Yes 1.02 1.5 -0.2 1.8
Average
FN-3 Intermediate Government 193.0 No 0.71 6.3 7.0 5.6
FN-4 Intermediate Government 18603.5 No 0.13 5.4 6.6 5.5
FN-5 Intermediate Government 142.6 No 0.60 5.9 6.7 5.4
FN-6 Intermediate Government 1401.6 No 0.54 5.7 6.4 6.2
FN-7 Intermediate Government 985.6 No 0.49 3.0 6.8 5.3
FN-11 Intermediate Government 1407.4 No 0.45 0.9 6.2 4.7
FN-22 Intermediate Government 192.7 No 0.70 3.2 6.0 4.9
FN-24 Intermediate Government 135.8 No 0.65 -1.1 6.0 4.6
FN-25 Intermediate Government 1807.3 Yes 0.80 7.8 6.1 4.9
FN-27 Intermediate Government 86.2 No 0.61 -0.2 5.6 4.4
FN-30 Intermediate Government 110.7 No 1.08 1.9 5.4 4.2
FN-31 Intermediate Government 619.7 Yes 0.96 5.0 5.9 4.9
FN-33 Intermediate Government 274.3 No 0.80 12.7 6.1 5.0
FN-34 Intermediate Government 891.8 Yes 0.88 4.2 6.6 5.1
FN-35 Intermediate Government 94.7 Yes 0.83 3.5 6.4 5.1
FN-39 Intermediate Government 588.8 Yes 0.96 5.2 6.7 5.3
FN-41 Intermediate Government 1080.4 No 0.95 3.5 6.0 4.7
FN-43 Intermediate Government 4472.2 Yes 0.64 2.2 5.5 4.4
FN-49 Intermediate Government 332.5 Yes 1.00 3.7 4.7 4.0
FN-51 Intermediate Government 17.3 No 1.58 2.1 4.9 3.7
FN-53 Intermediate Government 530.7 Yes 0.92 4.6 5.5 4.5
FN-57 Intermediate Government 123.8 No 0.75 6.4 3.3 3.2
FN-61 Intermediate Government 107.2 No 0.90 0.1 5.3 4.0
FN-62 Intermediate Government 135.6 Yes 1.15 3.7 5.9 4.4
FN-68 Intermediate Government 154.6 Yes 0.90 2.9 2.4 2.6
FN-70 Intermediate Government 1011.1 Yes 0.87 1.4 1.6 2.3
FN-74 Intermediate Government 583.5 No 0.50 6.0 7.3 5.7
FN-75 Intermediate Government 56.1 No 0.65 0.7 5.2 4.4
FN-78 Intermediate Government 84.7 Yes 1.00 -0.6 2.5 2.5
FN-80 Intermediate Government 611.7 No 0.51 6.5 6.8 5.5
FN-83 Intermediate Government 88.0 No 0.82 2.0 5.8 4.5
FN-86 Intermediate Government 358.0 Yes 1.06 0.5 4.9 4.0
FN-90 Short Term Corporate 1922.0 Yes 1.08 12.1 5.5 5.0
FN-97 Short Term Corporate 146.3 No 0.55 12.2 5.8 4.8
FN-98 Short Term Corporate 49.2 No 0.60 10.0 5.0 4.6
FN-101 Short Term Corporate 122.3 No 0.53 7.3 5.9 4.6
FN-102 Short Term Corporate 725.9 No 0.68 15.5 5.9 4.7
FN-103 Short Term Corporate 1248.4 No 0.72 14.0 5.5 4.7
FN-106 Short Term Corporate 605.2 No 0.30 8.1 4.1 3.7
FN-107 Short Term Corporate 1879.2 No 0.48 9.6 4.9 4.2
FN-108 Short Term Corporate 964.7 Yes 0.85 12.9 7.1 5.3
FN-109 Short Term Corporate 325.3 No 0.53 10.7 4.5 4.1
FN-110 Short Term Corporate 69.8 No 0.90 6.0 4.6 3.8
FN-112 Short Term Corporate 156.6 No 0.63 12.0 6.3 4.9
FN-113 Short Term Corporate 244.9 No 0.81 16.4 5.5 4.6
FN-114 Short Term Corporate 475.5 Yes 0.91 6.0 6.4 4.7
FN-115 Short Term Corporate 46.1 No 0.92 5.4 4.2 3.6
FN-116 Short Term Corporate 181.3 No 0.36 4.9 4.5 3.8
FN-117 Short Term Corporate 63.8 Yes 0.62 8.6 5.5 4.3
FN-121 Short Term Corporate 298.1 No 0.51 11.2 5.0 4.3
FN-122 Short Term Corporate 461.3 No 0.46 8.4 4.5 4.0
FN-124 Short Term Corporate 3662.7 No 0.52 9.0 5.2 4.3
FN-128 Short Term Corporate 5282.9 No 0.22 4.3 5.6 4.4
FN-130 Short Term Corporate 518.0 No 0.72 10.8 6.4 4.9
FN-137 Short Term Corporate 477.4 No 0.60 12.9 4.6 3.9
FN-138 Short Term Corporate 569.4 No 0.52 12.0 4.9 4.0
FN-141 Short Term Corporate 148.9 No 1.10 7.7 4.3 3.4
FN-142 Short Term Corporate 195.8 No 0.52 7.2 4.2 3.6
FN-146 Short Term Corporate 681.0 Yes 0.75 11.3 3.5 3.3
FN-149 Short Term Corporate 108.9 No 0.63 11.4 4.1 3.6
FN-154 Short Term Corporate 456.2 No 0.37 13.6 3.7 3.5
FN-156 Short Term Corporate 517.0 No 0.65 10.6 4.7 3.8
FN-158 Short Term Corporate 119.3 No 0.82 6.0 5.0 4.0
FN-159 Short Term Corporate 88.3 No 0.92 4.5 1.0 1.7
FN-160 Short Term Corporate 5701.6 Yes 0.69 6.7 3.4 3.1
FN-164 Short Term Corporate 230.6 No 0.95 13.9 3.5 3.2
FN-165 Short Term Corporate 115.7 Yes 0.70 11.5 1.8 2.4
FN-169 Short Term Corporate 246.1 No 0.75 11.9 0.8 2.0
FN-179 Short Term Corporate 249.7 No 0.55 2.4 0.4 1.5
Above average
FN-16 Intermediate Government 62.7 No 0.74 4.5 7.8 5.6
FN-26 Intermediate Government 4615.4 No 0.45 1.3 6.7 5.2
FN-32 Intermediate Government 628.7 No 0.55 2.1 6.3 5.1
FN-36 Intermediate Government 676.3 Yes 0.93 22.3 9.4 6.4
FN-37 Intermediate Government 1182.1 Yes 0.92 28.6 9.4 6.8
FN-40 Intermediate Government 40.0 No 1.94 17.1 6.6 5.1
FN-42 Intermediate Government 309.1 Yes 0.98 0.0 5.8 4.4
FN-44 Intermediate Government 498.7 Yes 0.95 0.9 4.9 4.1
FN-45 Intermediate Government 278.2 No 0.20 -3.8 6.0 4.7
FN-46 Intermediate Government 1525.5 No 0.13 -0.7 7.1 5.3
FN-47 Intermediate Government 556.6 Yes 0.94 7.9 5.5 4.3
FN-52 Intermediate Government 104.1 Yes 0.95 -3.6 4.7 3.7
FN-54 Intermediate Government 333.6 No 0.37 12.0 4.9 4.5
FN-56 Intermediate Government 322.5 Yes 1.13 4.7 5.6 4.4
FN-59 Intermediate Government 184.7 Yes 1.03 1.7 5.6 4.4
FN-60 Intermediate Government 122.7 No 0.26 -3.6 6.1 4.7
FN-63 Intermediate Government 82.2 No 0.57 -3.3 5.1 4.2
FN-64 Intermediate Government 305.7 Yes 0.99 3.0 6.2 4.9
FN-65 Intermediate Government 551.3 No 0.52 -1.4 7.3 5.2
FN-66 Intermediate Government 24.2 No 0.52 0.7 -0.1 1.2
FN-67 Intermediate Government 661.2 Yes 0.97 0.0 3.2 3.0
FN-69 Intermediate Government 106.9 Yes 0.79 -4.8 5.6 4.6
FN-71 Intermediate Government 634.8 Yes 0.90 7.3 3.7 3.4
FN-72 Intermediate Government 168.7 Yes 0.99 -2.9 6.0 4.1
FN-73 Intermediate Government 792.1 Yes 1.00 1.2 2.3 2.6
FN-77 Intermediate Government 640.3 No 0.27 0.2 6.5 5.2
FN-79 Intermediate Government 81.3 Yes 1.16 7.0 1.0 1.7
FN-82 Intermediate Government 131.3 No 0.65 -3.8 4.4 3.8
FN-85 Intermediate Government 3531.8 No 0.12 -1.6 7.2 5.4
FN-132 Short Term Corporate 93.9 No 0.74 9.4 5.5 4.3
FN-133 Short Term Corporate 1130.0 Yes 0.86 13.2 6.5 4.9
FN-134 Short Term Corporate 1101.9 No 0.64 13.0 3.5 3.8
FN-143 Short Term Corporate 2361.1 Yes 0.80 17.4 7.1 5.1
FN-144 Short Term Corporate 12.4 No 0.70 3.4 5.5 4.2
FN-145 Short Term Corporate 26.3 No 0.49 4.0 6.0 4.6
FN-147 Short Term Corporate 486.1 No 0.50 10.3 5.7 4.4
FN-148 Short Term Corporate 10744.6 No 0.46 13.4 6.5 4.9
FN-151 Short Term Corporate 128.3 No 0.55 8.8 5.9 4.5
FN-152 Short Term Corporate 374.4 No 0.73 13.2 4.6 3.8
FN-153 Short Term Corporate 280.6 Yes 0.99 16.6 8.0 4.6
FN-155 Short Term Corporate 16297.1 No 0.14 14.2 4.9 4.4
FN-157 Short Term Corporate 80.5 No 0.70 13.4 5.1 4.2
FN-162 Short Term Corporate 369.3 No 0.86 13.5 2.7 2.6
FN-163 Short Term Corporate 297.4 Yes 1.05 12.8 2.6 2.7
FN-167 Short Term Corporate 190.1 No 0.50 11.6 5.5 4.4
FN-168 Short Term Corporate 278.4 Yes 0.85 15.5 4.4 3.8
FN-170 Short Term Corporate 143.8 No 0.80 24.8 8.9 6.4
FN-171 Short Term Corporate 1469.6 Yes 1.08 29.7 4.8 4.3
FN-172 Short Term Corporate 80.0 No 0.70 9.9 2.9 3.0
FN-173 Short Term Corporate 95.5 No 0.66 19.2 0.0 1.3
FN-174 Short Term Corporate 170.5 No 0.46 15.6 0.7 2.0
FN-176 Short Term Corporate 237.1 No 0.50 14.5 0.7 1.7
FN-177 Short Term Corporate 983.0 No 0.60 15.2 0.2 1.9
FN-178 Short Term Corporate 51.9 No 0.70 13.4 0.1 1.2
FN-180 Short Term Corporate 33.8 No 0.53 16.4 0.7 1.8
FN-181 Short Term Corporate 249.8 Yes 0.43 6.7 -4.5 -1.5
FN-182 Short Term Corporate 52.9 No 0.87 5.2 -3.0 -0.7
FN-183 Short Term Corporate 39.7 No 0.51 -8.8 -13.8 -7.3
FN-184 Short Term Corporate 182.3 No 0.53 32.0 -2.7 0.2

gtExtras can plot and color style

Code
Bond.Table.Risk <- Bonds %>%
    group_by(Risk) %>%
    summarise(`Avg. Returns` = mean(Return.2009), `SD Returns` = sd(Return.2009),
        `Median Returns` = median(Return.2009), `Density Plots` = list(Return.2009),
        .groups = "drop")
Bond.Table.Risk %>%
    gt() %>%
    gtExtras::gt_plt_dist(`Density Plots`, type = "density", line_color = "blue",
        fill_color = "lightblue") %>%
    fmt_number(columns = 2:4, decimals = 2)
Risk Avg. Returns SD Returns Median Returns Density Plots
Above average 8.3 9.2 7.9
Average 6.9 4.4 6.0
Below average 6.3 2.7 6.1

flextable

The book on flextable

One Chunk Option You May Need

My flextable outputs don’t render well, and they don’t in general, with dark themes in reveal.js. You may need this if you make them images.

results=“hide”

One Thing I really Like

flexpivot

Code
library(flextable)
library(flexpivot)
Bonds %>%
    select(Fees, Risk) %>%
    pivot_table("Fees", "Risk") %>%
    pivot_format()

flexpivot

Another

Code
library(flexpivot)
library(flextable)
Bonds %>%
    select(Fees, Risk, Type) %>%
    pivot_table(rows = c("Type", "Risk"), cols = "Fees") %>%
    pivot_format() %>%
    theme_vanilla() %>%
    add_header_lines(values = "Risk, Fees, and Types") %>%
    save_as_html(path = "fpivot.html")

Model tables

I made a comment in the syllabus that is not quite right. stargazer is indeed nice for producing publication quality tables. But flextable can do this too.

Code
library(flextable)
library(tidyverse)
Model.Cars <- lm(dist ~ speed, data = cars)
as_flextable(Model.Cars) %>%
    theme_vanilla() %>%
    add_header_lines(values = "Regression from cars data") %>%
    save_as_html(path = "regress.html")

Summaries

Code
use_df_printer()
Bond.Funds <- read.csv(url("https://raw.githubusercontent.com/robertwwalker/DADMStuff/master/BondFunds.csv"),
    row.names = 1)
obj <- summarizor(Bond.Funds, by = "Risk", overall_label = "Overall")
obj %>%
    knitr::kable() %>%
    kableExtra::scroll_box(height = "60%")
variable stat cts percent data_type value1 value2 Risk
Type Intermediate Government 26 0.464 discrete NA NA Below average
Type Short Term Corporate 30 0.536 discrete NA NA Below average
Type missing 0 0.000 discrete NA NA Below average
Assets mean_sd NA NA continuous 780.818 1.63e+03 Below average
Assets median_iqr NA NA continuous 232.450 4.40e+02 Below average
Assets range NA NA continuous 17.400 7.27e+03 Below average
Assets missing 0 0.000 continuous NA NA Below average
Fees No 44 0.786 discrete NA NA Below average
Fees Yes 12 0.214 discrete NA NA Below average
Fees missing 0 0.000 discrete NA NA Below average
Expense.Ratio mean_sd NA NA continuous 0.702 2.09e-01 Below average
Expense.Ratio median_iqr NA NA continuous 0.675 3.45e-01 Below average
Expense.Ratio range NA NA continuous 0.320 1.13e+00 Below average
Expense.Ratio missing 0 0.000 continuous NA NA Below average
Return.2009 mean_sd NA NA continuous 6.314 2.71e+00 Below average
Return.2009 median_iqr NA NA continuous 6.100 3.17e+00 Below average
Return.2009 range NA NA continuous 0.200 1.30e+01 Below average
Return.2009 missing 0 0.000 continuous NA NA Below average
X3.Year.Return mean_sd NA NA continuous 4.754 1.57e+00 Below average
X3.Year.Return median_iqr NA NA continuous 4.950 2.20e+00 Below average
X3.Year.Return range NA NA continuous -0.200 7.50e+00 Below average
X3.Year.Return missing 0 0.000 continuous NA NA Below average
X5.Year.Return mean_sd NA NA continuous 4.109 9.34e-01 Below average
X5.Year.Return median_iqr NA NA continuous 4.100 1.32e+00 Below average
X5.Year.Return range NA NA continuous 1.800 6.10e+00 Below average
X5.Year.Return missing 0 0.000 continuous NA NA Below average
Type Intermediate Government 32 0.464 discrete NA NA Average
Type Short Term Corporate 37 0.536 discrete NA NA Average
Type missing 0 0.000 discrete NA NA Average
Assets mean_sd NA NA continuous 965.775 2.43e+03 Average
Assets median_iqr NA NA continuous 298.100 5.57e+02 Average
Assets range NA NA continuous 17.300 1.86e+04 Average
Assets missing 0 0.000 continuous NA NA Average
Fees No 49 0.710 discrete NA NA Average
Fees Yes 20 0.290 discrete NA NA Average
Fees missing 0 0.000 discrete NA NA Average
Expense.Ratio mean_sd NA NA continuous 0.722 2.42e-01 Average
Expense.Ratio median_iqr NA NA continuous 0.700 3.60e-01 Average
Expense.Ratio range NA NA continuous 0.130 1.58e+00 Average
Expense.Ratio missing 0 0.000 continuous NA NA Average
Return.2009 mean_sd NA NA continuous 6.871 4.39e+00 Average
Return.2009 median_iqr NA NA continuous 6.000 7.30e+00 Average
Return.2009 range NA NA continuous -1.100 1.64e+01 Average
Return.2009 missing 0 0.000 continuous NA NA Average
X3.Year.Return mean_sd NA NA continuous 5.013 1.54e+00 Average
X3.Year.Return median_iqr NA NA continuous 5.400 1.50e+00 Average
X3.Year.Return range NA NA continuous 0.400 7.30e+00 Average
X3.Year.Return missing 0 0.000 continuous NA NA Average
X5.Year.Return mean_sd NA NA continuous 4.200 9.62e-01 Average
X5.Year.Return median_iqr NA NA continuous 4.400 1.20e+00 Average
X5.Year.Return range NA NA continuous 1.500 6.20e+00 Average
X5.Year.Return missing 0 0.000 continuous NA NA Average
Type Intermediate Government 29 0.492 discrete NA NA Above average
Type Short Term Corporate 30 0.508 discrete NA NA Above average
Type missing 0 0.000 discrete NA NA Above average
Assets mean_sd NA NA continuous 969.407 2.56e+03 Above average
Assets median_iqr NA NA continuous 278.400 5.38e+02 Above average
Assets range NA NA continuous 12.400 1.63e+04 Above average
Assets missing 0 0.000 continuous NA NA Above average
Fees No 37 0.627 discrete NA NA Above average
Fees Yes 22 0.373 discrete NA NA Above average
Fees missing 0 0.000 discrete NA NA Above average
Expense.Ratio mean_sd NA NA continuous 0.709 3.11e-01 Above average
Expense.Ratio median_iqr NA NA continuous 0.700 4.30e-01 Above average
Expense.Ratio range NA NA continuous 0.120 1.94e+00 Above average
Expense.Ratio missing 0 0.000 continuous NA NA Above average
Return.2009 mean_sd NA NA continuous 8.314 9.24e+00 Above average
Return.2009 median_iqr NA NA continuous 7.900 1.31e+01 Above average
Return.2009 range NA NA continuous -8.800 3.20e+01 Above average
Return.2009 missing 0 0.000 continuous NA NA Above average
X3.Year.Return mean_sd NA NA continuous 4.166 3.81e+00 Above average
X3.Year.Return median_iqr NA NA continuous 5.500 3.45e+00 Above average
X3.Year.Return range NA NA continuous -13.800 9.40e+00 Above average
X3.Year.Return missing 0 0.000 continuous NA NA Above average
X5.Year.Return mean_sd NA NA continuous 3.619 2.20e+00 Above average
X5.Year.Return median_iqr NA NA continuous 4.300 1.95e+00 Above average
X5.Year.Return range NA NA continuous -7.300 6.80e+00 Above average
X5.Year.Return missing 0 0.000 continuous NA NA Above average
Type Intermediate Government 87 0.473 discrete NA NA Overall
Type Short Term Corporate 97 0.527 discrete NA NA Overall
Type missing 0 0.000 discrete NA NA Overall
Assets mean_sd NA NA continuous 910.648 2.25e+03 Overall
Assets median_iqr NA NA continuous 268.400 5.08e+02 Overall
Assets range NA NA continuous 12.400 1.86e+04 Overall
Assets missing 0 0.000 continuous NA NA Overall
Fees No 130 0.707 discrete NA NA Overall
Fees Yes 54 0.293 discrete NA NA Overall
Fees missing 0 0.000 discrete NA NA Overall
Expense.Ratio mean_sd NA NA continuous 0.712 2.56e-01 Overall
Expense.Ratio median_iqr NA NA continuous 0.700 3.75e-01 Overall
Expense.Ratio range NA NA continuous 0.120 1.94e+00 Overall
Expense.Ratio missing 0 0.000 continuous NA NA Overall
Return.2009 mean_sd NA NA continuous 7.164 6.09e+00 Overall
Return.2009 median_iqr NA NA continuous 6.400 7.25e+00 Overall
Return.2009 range NA NA continuous -8.800 3.20e+01 Overall
Return.2009 missing 0 0.000 continuous NA NA Overall
X3.Year.Return mean_sd NA NA continuous 4.663 2.52e+00 Overall
X3.Year.Return median_iqr NA NA continuous 5.100 2.05e+00 Overall
X3.Year.Return range NA NA continuous -13.800 9.40e+00 Overall
X3.Year.Return missing 0 0.000 continuous NA NA Overall
X5.Year.Return mean_sd NA NA continuous 3.986 1.49e+00 Overall
X5.Year.Return median_iqr NA NA continuous 4.300 1.30e+00 Overall
X5.Year.Return range NA NA continuous -7.300 6.80e+00 Overall
X5.Year.Return missing 0 0.000 continuous NA NA Overall

The flextable

Code
ft <- as_flextable(obj, spread_first_col = TRUE, separate_with = "variable")
ft %>%
    theme_vanilla() %>%
    save_as_image("img/SumTable.png", webshot = "webshot2")

Summary Table