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

[Bug]: decorate_grob_set fails when combining empty string and spaces in footnotes #1254

Open
3 tasks done
BFalquet opened this issue Jun 18, 2024 · 0 comments
Open
3 tasks done
Labels
bug Something isn't working sme

Comments

@BFalquet
Copy link

What happened?

This is a funny one:

This fails:

x <- chevron::run(chevron::mng01, chevron::syn_data, dataset = "adlb")
x <- lapply(x, ggplot2::ggplotGrob)

res <- tern::decorate_grob_set(
  x,
  titles = "title",
  footnotes = c("", "a a") # empty string and space
)
#> Error in if (grid::convertWidth(linewidth + gapwidth + width_i, grid::unitType(width), : missing value where TRUE/FALSE needed

This works

res <- tern::decorate_grob_set(
  x,
  titles = "title",
  footnotes = c(" ", "a a") # space and space
)

res <- tern::decorate_grob_set(
  x,
  titles = "title",
  footnotes = c("", "axa") # empty string and no space
)

res <- tern::decorate_grob_set(
  x,
  titles = "title",
  footnotes = c(" ", "axa") # blank space and no space
) 

res <- tern::decorate_grob_set(
  x,
  titles = "title",
  footnotes = c("a a", "") # blank space and empty string
)

The only condition where the function fails is when the first element of the vector is empty string and the other contains a blank space.

also when footnotes is NULL, the error is not very user friendly

x <- chevron::run(chevron::mng01, chevron::syn_data, dataset = "adlb")
x <- lapply(x, ggplot2::ggplotGrob)

res <- tern::decorate_grob_set(
  x,
  titles = "title",
  footnotes = NULL
)
#> Error in strsplit(text, " "): non-character argument
Created on 2024-06-18 with [reprex v2.1.0](https://reprex.tidyverse.org/)

Have fun!

sessionInfo()

No response

Relevant log output

> packageVersion("tern")
[1] ‘0.9.4.9009

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@BFalquet BFalquet added the bug Something isn't working label Jun 18, 2024
@edelarua edelarua added the sme label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sme
Projects
None yet
Development

No branches or pull requests

2 participants