cboettig / knitcitations

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

bibliography("html") produces error messages #92

Open lfaller opened 8 years ago

lfaller commented 8 years ago

Dear Dr Boettiger,

First of all, thanks for providing this package, it's really quite useful for me!

I've been using the citep function in my text and it works well, however, when trying to use the bibliography command, I can only get the plain no-argument version to run (bibliography()).

I tried using bibliography("html") but that throws error messages:

Error in mget(nom, envir = .BibOptions) : invalid first argument
Calls: <Anonymous> ... bibliography -> PrintBibliography -> BibOptions -> mget

I also tried using bibliography(style = 'nature', sorting = 'ynt'), which generated this message:

Error in cat(list(...), file, sep, fill, labels, append) : 
  argument 1 (type 'list') cannot be handled by 'cat'
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> bibliography -> cat

I'd appreciate any advice you might have in fixing these issues!

Best, ~Lina

PS: this is the output of sessionInfo in case it is useful.

> sessionInfo()
R Under development (unstable) (2016-03-30 r70404)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.3 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] knitcitations_1.0.7.1 devtools_1.10.0       ape_3.4               plyr_1.8.3            scales_0.4.0          ggplot2_2.1.0         phyloseq_1.15.13     
 [8] simboot_0.2-5         mvtnorm_1.0-5         boot_1.3-18           knitr_1.12.3         

loaded via a namespace (and not attached):
 [1] reshape2_1.4.1      splines_3.4.0       lattice_0.20-33     rhdf5_2.15.6        colorspace_1.2-6    htmltools_0.3.5     stats4_3.4.0        yaml_2.1.13        
 [9] mgcv_1.8-12         XML_3.98-1.4        chron_2.3-47        survival_2.38-3     withr_1.0.1         BiocGenerics_0.17.4 foreach_1.4.3       stringr_1.0.0      
[17] zlibbioc_1.17.1     Biostrings_2.39.12  munsell_0.4.3       gtable_0.2.0        codetools_0.2-14    memoise_1.0.0       labeling_0.3        Biobase_2.31.3     
[25] permute_0.9-0       IRanges_2.5.42      biomformat_0.99.2   parallel_3.4.0      curl_0.9.6          highr_0.5.1         Rcpp_0.12.4         vegan_2.3-4        
[33] S4Vectors_0.9.46    jsonlite_0.9.19     XVector_0.11.8      digest_0.6.9        stringi_1.0-1       RJSONIO_1.3-0       ade4_1.7-4          bibtex_0.4.0       
[41] bitops_1.0-6        tools_3.4.0         magrittr_1.5        RCurl_1.95-4.8      cluster_2.0.3       RefManageR_0.10.13  MASS_7.3-45         Matrix_1.2-4       
[49] data.table_1.9.6    lubridate_1.5.6     rmarkdown_0.9.5     httr_1.1.0          iterators_1.0.8     R6_2.1.2            multtest_2.27.0     igraph_1.0.1       
[57] nlme_3.1-126        git2r_0.14.0  
cboettig commented 8 years ago

I recommend using pandoc mode and the csl stylesheet of your choice to format the bibliography list. The html mode might need some debugging, sorry about that.

lfaller commented 8 years ago

Ok sounds good, thanks!!

suttonbm commented 8 years ago

I tried modifying the source for bibliography() as shown below, and this seems to be working now. Not sure I've considered every application, but maybe this will help...

bibliography <- function(style=NULL, ...)
{
  bibs <- get_bib()
  NoCite(bibs)

  if(is.null(style)){
    BibOptions(...)
    refs <- sapply(sort(bibs), csl_formatting)
    cat(refs, sep="\n")
  } else {
    PrintBibliography(bibs, .opts=list(style=style,...))
  }
  invisible(bibs)
}
lfaller commented 7 years ago

Great, thanks for this update!

suttonbm commented 7 years ago

Sure! I put in a pull request to update this in the repository... In the meantime I just have a local clone I installed separately. Feel free to use my fork in the meantime :).

https://github.com/suttonbm/knitcitations