I'm using skimr
, and I added two summary functions (iqr_na_rm
and median_na_rm
) to the list of summary functions for the function skim
. However, by default these new summary functions (called skimmers
in skimr
documentation) appear at the end of the table. Instead, I'd like median
and iqr
to appear after mean
and sd
.
The final goal is to show the results in a .Rmd
report like this:
---
title: "Test"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(warning = FALSE,
message = FALSE,
echo = FALSE)
```
## Test
```{r test, results = 'asis'}
library(skimr)
library(dplyr)
library(ggplot2)
iqr_na_rm <- function(x) IQR(x, na.rm = TRUE)
median_na_rm <- function(x) median(x, na.rm = TRUE)
skim_with(numeric = list(p50 = NULL, median = median_na_rm, iqr = iqr_na_rm),
integer = list(p50 = NULL, median = median_na_rm, iqr = iqr_na_rm))
msleep %>%
group_by(vore) %>%
skim(sleep_total) %>%
kable()
```
Rendered HTML:
As you can see, median
and iqr
are printed and the end of the table, after the sparkline histogram. I'd like them to be printed after sd
and before p0
. Is it possible?