cboettig / knitcitations

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

Stack imbalance, unexpected token value, entry$key in keys argument is of length zero #72

Closed elbamos closed 9 years ago

elbamos commented 9 years ago

I get oodles of errors trying this out; there are a consistent few, but nearly every call to citet() or citep() returns an error, including cut-and-pasted commands from the tutorial. I'm not sure if I am doing something fundamentally wrong here, or if there's some kind of configuration issue, or what.

Examples:

citep("http://cran.r-project.org/web/packages/knitcitations/vignettes/tutorial.pdf") Warning: stack imbalance in '.External', 83 then 86 Warning: stack imbalance in '<-', 81 then 84 Warning: stack imbalance in '{', 78 then 81 Warning: stack imbalance in '<-', 72 then 75 Warning: stack imbalance in '{', 69 then 72 Warning: stack imbalance in 'if', 67 then 70 Warning: stack imbalance in '{', 64 then 67 Warning: stack imbalance in 'if', 62 then 65 Warning: stack imbalance in '{', 59 then 62 Warning: stack imbalance in '<-', 53 then 56 Warning: stack imbalance in 'if', 51 then 54 Warning: stack imbalance in 'if', 49 then 52 Warning: stack imbalance in '{', 46 then 49 Warning: stack imbalance in 'if', 44 then 47 Warning: stack imbalance in 'if', 42 then 45 Warning: stack imbalance in '{', 39 then 42 Warning: stack imbalance in '<-', 33 then 36 Warning: stack imbalance in '{', 30 then 33 Warning: stack imbalance in 'lapply', 18 then 21 Warning: stack imbalance in '<-', 9 then 12 Warning: stack imbalance in '{', 6 then 9 [1] "" Warning message: In ReadBib(con) : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/greycite.bibaffd978cf1:4:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) read.bibtex("./notebook/hlft.bib") Warning: stack imbalance in '.External', 15 then 18 Warning: stack imbalance in '<-', 13 then 16 Warning: stack imbalance in '{', 10 then 13 Warning message: In ReadBib(file, .Encoding = .Encoding, header = NULL, footer = NULL, : ./notebook/hlft.bib:8:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) bibliography() citet("http://mpqa.cs.pitt.edu/") Warning: stack imbalance in '.External', 83 then 86 Warning: stack imbalance in '<-', 81 then 84 Warning: stack imbalance in '{', 78 then 81 Warning: stack imbalance in '<-', 72 then 75 Warning: stack imbalance in '{', 69 then 72 Warning: stack imbalance in 'if', 67 then 70 Warning: stack imbalance in '{', 64 then 67 Warning: stack imbalance in 'if', 62 then 65 Warning: stack imbalance in '{', 59 then 62 Warning: stack imbalance in '<-', 53 then 56 Warning: stack imbalance in 'if', 51 then 54 Warning: stack imbalance in 'if', 49 then 52 Warning: stack imbalance in '{', 46 then 49 Warning: stack imbalance in 'if', 44 then 47 Warning: stack imbalance in 'if', 42 then 45 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(con) : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/greycite.bibaff245bc65a:6:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) citet("10.1007/978-0-387-32348-0" ... ) Warning: stack imbalance in '.External', 87 then 90 Warning: stack imbalance in '<-', 85 then 88 Warning: stack imbalance in '{', 82 then 85 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff53b515c.bib:7:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) cleanbib() citet("10.1007/978-0-387-32348-0") Warning: stack imbalance in '.External', 87 then 90 Warning: stack imbalance in '<-', 85 then 88 Warning: stack imbalance in '{', 82 then 85 [1] "" Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff795a71b2.bib:7:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) citet("10.1007/978-0-387-32348-0") Warning: stack imbalance in '.External', 87 then 90 Warning: stack imbalance in '<-', 85 then 88 Warning: stack imbalance in '{', 82 then 85 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff20de9b5c.bib:7:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) citep(citation("topicmodels")) [1] "(Grün and Hornik, 2011)" citep("topic") Error in entry$author : $ operator is invalid for atomic vectors In addition: Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff76a9c5df.bib:36:0 syntax error, unexpected $end Dropping the entry greycite23128 (starting at line 1) citet("10.1007/978-0-387-32348-0") Warning: stack imbalance in '.External', 87 then 90 Warning: stack imbalance in '<-', 85 then 88 Warning: stack imbalance in '{', 82 then 85 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff3fdf056.bib:7:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) bibliography() Grün, B. and K. Hornik. “topicmodels: An R Package for Fitting Topic Models”. In: Journal of Statistical Software 40.13 (2011), pp. 1-30. URL: http://www.jstatsoft.org/v40/i13/. citep("topicmodels") Query "topicmodels" returned no matches Error in entry$author : $ operator is invalid for atomic vectors citep("topicmodels", author = "Hornik") Error in ReadCrossRef(x, limit = 1, ...) : unused argument (author = "Hornik") citep(author = "Hornik") Error in lapply(x, knit_cite, ...) : argument "x" is missing, with no default citep(x = "Hornik") Warning: stack imbalance in '.External', 87 then 90 Warning: stack imbalance in '<-', 85 then 88 Warning: stack imbalance in '{', 82 then 85 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff79902c79.bib:11:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) citep("http://knowledgeblog.org/greycite") Warning: stack imbalance in '.External', 83 then 86 Warning: stack imbalance in '<-', 81 then 84 Warning: stack imbalance in '{', 78 then 81 Warning: stack imbalance in '<-', 72 then 75 Warning: stack imbalance in '{', 69 then 72 Warning: stack imbalance in 'if', 67 then 70 Warning: stack imbalance in '{', 64 then 67 Warning: stack imbalance in 'if', 62 then 65 Warning: stack imbalance in '{', 59 then 62 Warning: stack imbalance in '<-', 53 then 56 Warning: stack imbalance in 'if', 51 then 54 Warning: stack imbalance in 'if', 49 then 52 Warning: stack imbalance in '{', 46 then 49 Warning: stack imbalance in 'if', 44 then 47 Warning: stack imbalance in 'if', 42 then 45 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(con) : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/greycite.bibaff6857fa48:9:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) citep(citation("knitr")) [1] "(Xie, 2014a; Xie, 2013; Xie, 2014b)" citet("10.1098/rspb.2013.1372") Warning: stack imbalance in '.External', 87 then 90 Warning: stack imbalance in '<-', 85 then 88 Warning: stack imbalance in '{', 82 then 85 Error in if (entry$key %in% keys) { : argument is of length zero In addition: Warning message: In ReadBib(file = temp.file, .Encoding = "UTF-8") : /var/folders/s1/_v14lsc56tv44hm304m07vn40000gq/T//RtmpgxJKCa/fileaff67f0c27c.bib:13:1 syntax error, unexpected TOKEN_VALUE, expecting TOKEN_LBRACE Dropping the entry greycite23128 (starting at line 1) bibliography() Grün, B. and K. Hornik. “topicmodels: An R Package for Fitting Topic Models”. In: Journal of Statistical Software 40.13 (2011), pp. 1-30. URL: http://www.jstatsoft.org/v40/i13/.

Xie, Y. Dynamic Documents with R and knitr. ISBN 978-1482203530. Boca Raton, Florida: Chapman and Hall/CRC, 2013. URL: http://yihui.name/knitr/.

Xie, Y. “knitr: A Comprehensive Tool for Reproducible Research in R”. In: Implementing Reproducible Computational Research. Ed. by V. Stodden, F. Leisch and R. D. Peng. ISBN 978-1466561595. Chapman and Hall/CRC, 2014. URL: http://www.crcpress.com/product/isbn/9781466561595.

Xie, Y. knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.8.2. 2014. URL: http://yihui.name/knitr/.

cboettig commented 9 years ago

hmm, I cannot reproduce this. Are you still getting this error? Can you send me the output of sessionInfo() after you get these errors?

sorry for the long turn-around.

elbamos commented 9 years ago

Right now I've wrapped citet and citep layer that embeds them in tryCatch(). What's happening seems to be related to RefManageR not being able to parse some Zotero output. When different slices of the same data get passed into knitcitations -- for example, by telling it to load the output of two ReadZotero calls -- then the problem begins. And for whatever reason, cleanbib() isn't cleaning it up, so it gets worse and worse on each call. Is there any way to get knitcitations to produce some kind of diagnostic ouput or verbose logging for me to send you?

cboettig commented 9 years ago

Thanks for the reply. Can you give me a minimal example that I can use to reproduce this error? It sounds like it is related to the caching of bibdata in either RefManageR or knitcitations. Also let me know the output of sessionInfo()

elbamos commented 9 years ago

I have tried, and I can't get to a minimal example. The issue happens sometimes, usually when its the first time I knit my file after starting a new R session. Sometimes it doesn't happen. I haven't located a precise thing that determines whether the knit will fail. The collection of materials is on Zotero in a public repository at G55WMD92. If it would help, I can also provide the inline citations (i.e., the ones to URLs.)

cboettig commented 9 years ago

okay, thanks for trying. Sounds like this may be due to specific examples in the Zotero collection and not the tutorial examples then? Without a reproducible example of the error I cannot really debug, so I'll close this for the time being. Anyone who can reproduce the error should feel free to reopen / add additional comments here.