crsh / citr

RStudio Addin to Insert Markdown Citations
Other
407 stars 46 forks source link

citr::tidy_bib_file doesn't find references #49

Closed heinonmatti closed 4 years ago

heinonmatti commented 5 years ago

So, this happens:

I write: citr::tidy_bib_file(rmd_file = "../_citr-test.Rmd", messy_bibliography = "baseline-visu.bib")

I get: Error in citr::tidy_bib_file(rmd_file = "../_citr-test.Rmd", messy_bibliography = "baseline-visu.bib") : Found no references in ../_citr-test.Rmd

Attached the bibliography and the Rmd file. citr-test.zip

Session info:

[1] C:/rlibs/3.4.2 [2] C:/Program Files/R/R-3.5.1/library

crsh commented 5 years ago

Hi Matti,

I think this is a duplicate of https://github.com/crsh/citr/issues/48. Could you try installing citr from this GitHub repository to see if that fixes it?

heinonmatti commented 5 years ago

Yeah you're right, works now.

Perhaps it might be a good idea to have it ignore e-mail addresses at some point?

(here's what I got:)

The following references could not be found: gmail.com", uef.fi", helsinki.fi", thl.fi", ncl.ac.uk", uta.fi", hankonenRandomisedControlledFeasibility2017)., hankonenLetMoveIt2016)., tibshiraniRegressionShrinkageSelection1996), husuObjectivelyMeasuredSedentary2016a), heveyNetworkAnalysisBrief2018)., epskampTutorialRegularizedPartial2018)

heinonmatti commented 5 years ago

Wait, apparently it wiped the bibiliography clean :-o

crsh commented 5 years ago

I have added a regex for the e-mail addresses. Thanks for the suggestion. However, I cannot reproduce the wiping of the bibliography. I do the following:

> library(citr)
> tidy_bib_file(rmd_file = "./citr-test/_citr-test.Rmd", messy_bibliography = "./citr-test/baseline-visu.bib", file = "./citr-test/cleaned.bib")

and I get

Removing 1136 unneeded bibliography entries.
Writing 32 Bibtex entries ... OK
Results written to file ‘./citr-test/cleaned.bib’
Warnings:
1: In strsplit(x, rx) : Input string 1 is invalid in this locale
2: In tidy_bib_file(rmd_file = "~/Downloads/citr-test/_citr-test.Rmd",  :
  Only found 32 out of 33 necessary references in the look-up bibliography. The following references could not be found:
  hankonenRandomisedControlledFeasibility2017).
3: In y[xx < 512] <- utf8table[xx] :
  Number of items to replace is not a multiple of replacement length

Warnings 1 and 3 appear to be related to non-UTF-8 characters in the Rmd, is that possible?

heinonmatti commented 5 years ago

I don't know what's wrong. Cleaned.bib is empty and I get this, even though I think (?) the refs are in the bib-file:

Removing 1121 unneeded bibliography entries. Writing 70 Bibtex entries ... Error in .BibEntryCheckBibEntry1(x[[i]]) : danielsAverageMan1952: A bibentry of bibtype ‘Report’ has to specify the field: type In addition: Warning message: In citr::tidy_bib_file(rmd_file = "./_baseline-manuscript.Rmd", : Only found 70 out of 77 necessary references in the look-up bibliography. The following references could not be found: hankonenParticipantsEnactmentBehavior2018)., hankonenLetMoveIt2016)., heinoSourceCodeVisualisation2019), tibshiraniRegressionShrinkageSelection1996), husuObjectivelyMeasuredSedentary2016a), heveyNetworkAnalysisBrief2018)., epskampTutorialRegularizedPartial2018)

I'll enclose the .bib and .rmd!

baseline-visu.zip

crsh commented 4 years ago

Hi Matti, I've finally found some time to look into this again. The references that were reported to be missing were due to "incorrect" citation where the citation was used in parentheses, e.g. (this and that; @citation) instead of [this and that; @citation]. This should now be fixed.

The error while writing out the remaining entries was caused by RefManageR checking the validity of the entered information during writing. I have now disabled these checks, which fixed this issue for me. Let me know, if you find the time to try it out, whether that resolves the problem for you, too.