Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option like na.rm = TRUE #28

Open
balthasars opened this issue Apr 2, 2021 · 2 comments
Open

option like na.rm = TRUE #28

balthasars opened this issue Apr 2, 2021 · 2 comments
Labels
idea New feature or request

Comments

@balthasars
Copy link

balthasars commented Apr 2, 2021

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

@k5cents
Copy link
Owner

k5cents commented Apr 2, 2021

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)).

@k5cents k5cents added the idea New feature or request label Apr 2, 2021
@k5cents
Copy link
Owner

k5cents commented Apr 13, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants