cboettig / knitcitations

:package: Generate citations for knitr markdown and html files
http://carlboettiger.info
Other
220 stars 28 forks source link

citep error for dplyr package citation - Windows #104

Open melindahiggins2000 opened 6 years ago

melindahiggins2000 commented 6 years ago

Here is my reproducible example. When I use citep() with the citation() function, I get an error. I'm running Windows 10, R 3.4.3; RStudio 1.1.383. My sessionInfo() is listed below, along with the code that produces the error Error in nchar(aut) : invalid multibyte string, element 1.

Note: citep() works fine for most of the other packages I'm currently citing in my project. I would appreciate any suggestions on how to fix this citation for the dplyr package.

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

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

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

loaded via a namespace (and not attached):
 [1] compiler_3.4.3  backports_1.1.1 bookdown_0.5.10
 [4] magrittr_1.5    rprojroot_1.3-2 htmltools_0.3.6
 [7] tools_3.4.3     yaml_2.1.16     Rcpp_0.12.13   
[10] stringi_1.1.5   rmarkdown_1.8.5 knitr_1.18     
[13] stringr_1.2.0   digest_0.6.12   evaluate_0.10.1
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> library(knitcitations)
> citep(citation("dplyr"))
Error in nchar(aut) : invalid multibyte string, element 1
> citation("dplyr")

To cite package ‘dplyr’ in publications use:

  Hadley Wickham, Romain Francois, Lionel Henry and
  Kirill Müller (2017). dplyr: A Grammar of Data
  Manipulation. R package version 0.7.4.
  https://CRAN.R-project.org/package=dplyr

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {dplyr: A Grammar of Data Manipulation},
    author = {Hadley Wickham and Romain Francois and Lionel Henry and Kirill Müller},
    year = {2017},
    note = {R package version 0.7.4},
    url = {https://CRAN.R-project.org/package=dplyr},
  }
cboettig commented 6 years ago

Seems to be related to how Windows is handling the UTF-8 characters (controlled by your locale settings), but not sure quite where it goes wrong (don't have a Windows box handy to debug, can't reproduce the error on Linux + Mac).

Can you try:

citep( RefManageR::as.BibEntry(citation("dplyr") ) )
melindahiggins2000 commented 6 years ago

I still get the same error - here are my code results:

> RefManageR::as.BibEntry(citation("dplyr"))
[1] H. Wickham, R. Francois, L. Henry, et al. _dplyr: A
Grammar of Data Manipulation_. R package version 0.7.4.
2017. <URL: https://CRAN.R-project.org/package=dplyr>.

> citep(RefManageR::as.BibEntry(citation("dplyr")))
Error in nchar(aut) : invalid multibyte string, element 1

By the way, this is not a show stopper when I'm running it inside of my Rmarkdown document. The document does compile, but this is what I get for the dplyr reference in my document - basically the authors are stripped off. Something in the dplyr author list is causing the issue, I think...

? 2017. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.