ropensci / RefManageR

R package RefManageR
https://docs.ropensci.org/RefManageR
Other
114 stars 25 forks source link

Inconsistent citation keys patterns #68

Open egoipse opened 4 years ago

egoipse commented 4 years ago

Hi,

The citation keys patterns taken by RefManageR from Zotero are inconsistent and do not allow to incorporate bib references in RMarkdown correctly.

Creating a biblio file with ReadZotero function generates the following citation keys:

@Book{wickham_ggplot2:_2018,
  title = {ggplot2: {Elegant} {Graphics} for {Data} {Analysis}},
  shorttitle = {ggplot2},
  url = {https://ggplot2-book.org/},
  abstract = {Master ggplot2 and the rich grammar that underlies it.},
  urldate = {2019-07-27},
  author = {Hadley Wickham},
  year = {2018},
  keywords = {gráficos, r, tema 2, tutoriales},
}

@Misc{rcoreteamLanguageEnvironmentStatistical2019,
  address = {Viena},
  title = {R: {A} language and environment for statistical computing},
  url = {https://www.R-project.org/},
  publisher = {R Foundation for Statistical Computing},
  author = {{R Core Team}},
  year = {2019},
  keywords = {base, core, r, rprogramabase, software, tema 2},
}

@Book{chang_r_2019,
  title = {R {Graphics} {Cookbook}, 2nd edition},
  url = {https://r-graphics.org},
  abstract = {This cookbook contains more than 150 recipes to help scientists, engineers, programmers, and data analysts generate high-quality graphs quickly—without having to comb through all the details of R’s graphing systems. Each recipe tackles a specific problem with a solution you can apply to your own project and includes a discussion of how and why the recipe works.},
  urldate = {2019-07-27},
  author = {Winston Chang},
  year = {2019},
  keywords = {ggplot, gráficos, r, tema 2, tutoriales},
}

As you can see, the citation keys for books are totally diferent than from misc publication. The format I defined in Zotero Better BibTex plugin is exactly the misc's one. The output when exporting the same bilbliographic references directly from Zotero are exactly as I defined:

@book{wickhamggplot2ElegantGraphics2018,
  title = {Ggplot2: {{Elegant Graphics}} for {{Data Analysis}}},
  shorttitle = {Ggplot2},
  abstract = {Master ggplot2 and the rich grammar that underlies it.},
  author = {Wickham, Hadley},
  year = {2018},
  keywords = {r,tutoriales,gráficos,tema 2}
}

@misc{rcoreteamRlanguageenvironment2019,
  address = {{Viena}},
  title = {R: {{A}} Language and Environment for Statistical Computing},
  howpublished = {R Foundation for Statistical Computing},
  author = {{R Core Team}},
  year = {2019},
  keywords = {base,core,r,rprogramabase,software,tema 2}
}

@book{changRGraphicsCookbook2019,
  title = {R {{Graphics Cookbook}}, 2nd Edition},
  abstract = {This cookbook contains more than 150 recipes to help scientists, engineers, programmers, and data analysts generate high-quality graphs quickly\textemdash{}without having to comb through all the details of R's graphing systems. Each recipe tackles a specific problem with a solution you can apply to your own project and includes a discussion of how and why the recipe works.},
  author = {Chang, Winston},
  year = {2019},
  keywords = {r,ggplot,tutoriales,gráficos,tema 2}
}

I know that misc item is pined as fixed key citation and the other ones do not, so that would explain the issue. Am I right? And if the case, is there other solution to the issue?

mwmclean commented 4 years ago

Please provide a minimal working example using ReadZotero and RMarkdown that demonstrates the issue you refer to with RMarkdown. The keys are different, but they're still unique and valid, so what's the problem?

egoipse commented 4 years ago

Please provide a minimal working example using ReadZotero and RMarkdown that demonstrates the issue you refer to with RMarkdown.

Sure. Here it is:

require(RefManageR)
biblio<-ReadZotero(user=xxxxxxx, .params = list(tag="Tema 2", key="xxxxxxxxxxxxxxxxxxxx" ), delete.file = FALSE)
WriteBib(biblio, file = "bibliografia.bib", biblatex = TRUE)

The keys are different, but they're still unique and valid, so what's the problem?

The problem is that it is not possible the automatization of working flow. Since I cannot predict the citation key pattern, I have to create first the Bib file and then copy manually the key generated by RefManageR. It is not precisely an efficient workflow. I use reprex addin to copy the exact citation key from Zotero. So, if RefManageR creates a file with a citation key pattern diferent than the one I defined, it is not possible an automatic workflow.