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

behavior of combine_words when vector length is 2 and the and option is empty #2044

Closed
3 tasks done
eitsupi opened this issue Sep 20, 2021 · 3 comments · Fixed by #2045
Closed
3 tasks done

behavior of combine_words when vector length is 2 and the and option is empty #2044

eitsupi opened this issue Sep 20, 2021 · 3 comments · Fixed by #2045
Labels
bug Bugs

Comments

@eitsupi
Copy link

eitsupi commented Sep 20, 2021

Thank you for your continued development of great packages.

I was confused when the vector length given to combine_words was 2.

> knitr::combine_words(c("a", "b", "c"), before = "`", and = "")
`a`, `b`, `c`
> knitr::combine_words(c("a", "b"), before = "`", and = "")
`a``b`

The outputs I wanted were `a`, `b`, `c` and `a`, `b`.
Currently, to get the output of like that, we need to set and to the same content as sep, and also set oxford_comma to FALSE.

> knitr::combine_words(c("a", "b", "c"), before = "`", and = ", ", oxford_comma = FALSE)
`a`, `b`, `c`
> knitr::combine_words(c("a", "b"), before = "`", and = ", ", oxford_comma = FALSE)
`a`, `b`

How about changing to separate words with sep when and is empty even if the length is 2?


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

> xfun::session_info('knitr')
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
  LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
  LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
  LC_PAPER=en_US.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C            
  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

Package version:
  evaluate_0.14   glue_1.4.2      graphics_4.1.1  grDevices_4.1.1
  highr_0.9       knitr_1.34      magrittr_2.0.1  methods_4.1.1  
  stats_4.1.1     stringi_1.7.4   stringr_1.4.0   tools_4.1.1    
  utils_4.1.1     xfun_0.25       yaml_2.2.1 
@yihui yihui added the bug Bugs label Sep 20, 2021
@yihui
Copy link
Owner

yihui commented Sep 20, 2021

This sounds like a bug. @cderv Could you take a look and fix it? I guess it shouldn't be hard to fix. Thanks!

@eitsupi
Copy link
Author

eitsupi commented Sep 22, 2021

Thank you for the quick fix!

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants