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

strsplit(x, split = ";") error #31

Closed
sciencificity opened this issue Sep 8, 2021 · 4 comments · Fixed by #38
Closed

strsplit(x, split = ";") error #31

sciencificity opened this issue Sep 8, 2021 · 4 comments · Fixed by #38

Comments

@sciencificity
Copy link

Dear Danielle,

Thank you for this package. I am keen to use it to create neat little cards for code snippets for myself (and anyone else who stumbles on it) on my distill blog.

I downloaded the CRAN bs4cards and ran the example code of

galleries %>%
  cards(
    title = long_name,
    text = blurb,
    image = image_url,
    link = gallery_url
  )

in an RMarkdown document with the ffg. in the YAML header:

output:
  html_document:
    theme:
      version: 4

I get an error as follows however: "Error in strsplit(x, split = ";") : non-character argument Calls: ... dots_list -> card_class -> unique_tags -> unlist -> strsplit"

I tried adding tags as follows and I experience the same error.

galleries %>%
  cards(
    title = long_name,
    text = blurb,
    image = image_url,
    link = gallery_url,
    tags = paste0("All;", "R")
  )

I also copied the unique_tags and card_class functions into my R code, and ran it on card_class(paste0("All;", "R")) which worked 100%.

The only package I do not have is methods which is in the imports section. I am unsure if that is the issue but I cannot find a CRAN version of it. I tried to do a reprex but the error experienced is that it could not find function '%>%' which is not the problem I am experiencing (I also purposely loaded magrittr, which made no difference). I am on version 3.6.3 of R but the depends is > 2.10, so I am hoping it is not that. I suspect I am doing something stupid or missing something essential and I would appreciate the help.

My sessionInfo:
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_South Africa.1252
[2] LC_CTYPE=English_South Africa.1252
[3] LC_MONETARY=English_South Africa.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_South Africa.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] reprex_2.0.1 bs4cards_0.1.0

loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.33 magrittr_2.0.1
[4] R6_2.5.0 rlang_0.4.11 fastmap_1.1.0
[7] fansi_0.4.2 highr_0.8 styler_1.3.2
[10] tools_3.6.3 xfun_0.21 utf8_1.2.1
[13] cli_2.3.1 clipr_0.7.1 withr_2.4.1
[16] htmltools_0.5.2 ellipsis_0.3.1 assertthat_0.2.1
[19] yaml_2.2.1 digest_0.6.27 tibble_3.1.0
[22] lifecycle_1.0.0 crayon_1.4.1 processx_3.5.0
[25] callr_3.6.0 purrr_0.3.4 ps_1.6.0
[28] vctrs_0.3.7 fs_1.5.0 rsconnect_0.8.16
[31] glue_1.4.2 evaluate_0.14 rmarkdown_2.10
[34] compiler_3.6.3 pillar_1.5.1 backports_1.2.1
[37] pkgconfig_2.0.3

PS: I first tried it on a new page I was creating on my distill blog where I downloaded and used the "strapless.css":

output:
  distill::distill_article:
    css: "strapless.css"

Thank you!

@djnavarro
Copy link
Owner

Hi!

Thanks for trying out the package. That looks suspiciously like a bug 🐛 in the function that parses the tag, so I think the problem is at my end. I doubt it's anything to do with your R environment (methods is one of the base packages, so you're all set there). Almost certainly the issue is that I didn't write very robust code for handling the inputs there. I'll aim to take a look at this soon, and thanks so much for reporting the problem!

Best,
Danielle

@gadenbuie
Copy link
Contributor

I think the root of this issue comes down to stringsAsFactors strikes again (for those of us still working with R <= 3.6.3). You should be able to get around the problem right now using

options(stringsAsFactors = FALSE)

@sciencificity
Copy link
Author

Ag, that makes sense. Thanks Garrick. I guess stringsAsFactors really is = . I got a new laptop and upgraded to version 4.1.1 and the problem does not exist there.
Thanks so much for the package Danielle, it is lovely!

@djnavarro
Copy link
Owner

Brilliant, thanks @gadenbuie! I'll merge #38 now, hopefully fixing this! Thanks for opening the issue @sciencificity

djnavarro pushed a commit that referenced this issue Nov 29, 2021
* Protect against non-character weirdness with tags and labels

Fixes #31

* Add NEWS item
djnavarro pushed a commit that referenced this issue Nov 29, 2021
* Protect against non-character weirdness with tags and labels

Fixes #31

* Add NEWS item

* Use columns in `data` by default if available

Without stepping on the user's input, so they can turn this off if they want

Fixes #40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants