gluedown
gluedown copied to clipboard
option like `na.rm = TRUE`
Hi there!
I wanted to ask if there is a way for NAs not to occur in the output of the md_-functions, similar to the na.rm = TRUE option in sum() and other similar functions, such that the following doesn't occur:
library(gluedown)
one <- c("one", "two", NA)
md_bullet(one)
#> * one
#> * two
#> * NA
Created on 2021-04-02 by the reprex package (v1.0.0)
All the best and thanks for the package
There isn't a way as of right now, but it could be added. I'll have to think about whether or not it should be an argument and look at some examples of how other packages handle it. You could always call md_bullet(na.omit(one)).
NA values could potentially be treated like "empty" list elements.
md_bullet <- function(x, marker = c("*", "-", "+")) {
marker <- match.arg(marker)
x[is.na(x)] <- ""
glue::glue("{marker} {x}")
}
md_bullet(x = c(1, NA, 2))
- 1
- 2
Created on 2021-04-13 by the reprex package (v1.0.0)