问题描述
我正在尝试使用knitcitations
并将书目添加到我在R Studio中起草的R Markdown文档中.我的文档的标题如下:
I'm trying to use knitcitations
and add bibliography to the R Markdown document that I'm drafting in R Studio. The header of my document looks like this:
---
title: "Some Title"
author: "Me"
date: "September 2015"
bibliography: bibliography.bib
output:
pdf_document:
highlight: tango
number_sections: yes
toc: yes
---
我想使用以下代码在最后添加书目:
I want to add the bibliography at the end using the following code:
```{r generateBibliography, echo=FALSE, eval=TRUE, message=FALSE, warning=FALSE}
require("knitcitations")
cleanbib()
options("citation_format" = "pandoc")
read.bibtex(file = "bibliography.bib")
```
参考文件bibliography.bib
具有以下内容:
The reference file bibliography.bib
has the following content:
@article{debarsy_testing_2010,
title = {Testing for spatial autocorrelation in a fixed effects panel data model},
volume = {40},
issn = {0166-0462},
url = {http://www.sciencedirect.com/science/article/pii/S0166046210000451},
doi = {10.1016/j.regsciurbeco.2010.06.001},
abstract = {The aim of this paper is to assess the relevance of spatial autocorrelation in a fixed effects panel data model and in the affirmative, to identify the most appropriate spatial specification as this appears to be a crucial point from the modeling perspective of interactive heterogeneity. Several {LM} test statistics as well as their {LR} counterparts, which allow discriminating between endogenous spatial lag versus spatially autocorrelated errors, are therefore proposed. Monte Carlo experiments show their good finite sample performance. Finally, an empirical application is provided in the framework of the well-known Feldstein–Horioka puzzle.},
pages = {453--470},
number = {6},
journaltitle = {Regional Science and Urban Economics},
shortjournal = {Regional Science and Urban Economics},
author = {Debarsy, Nicolas and Ertur, Cem},
urldate = {2015-10-01},
date = {2010-11},
keywords = {Panel data, Spatial autocorrelation, Test statistics},
file = {complex_zotero_path}
}
@article{lamichhane_spatial-temporal_2015,
title = {Spatial-Temporal Modeling of Neighborhood Sociodemographic Characteristics and Food Stores},
volume = {181},
issn = {0002-9262, 1476-6256},
url = {http://aje.oxfordjournals.org/content/181/2/137},
doi = {10.1093/aje/kwu250},
abstract = {The literature on food stores, neighborhood poverty, and race/ethnicity is mixed and lacks methods of accounting for complex spatial and temporal clustering of food resources. We used quarterly data on supermarket and convenience store locations from Nielsen {TDLinx} (Nielsen Holdings N.V., New York, New York) spanning 7 years (2006–2012) and census tract-based neighborhood sociodemographic data from the American Community Survey (2006–2010) to assess associations between neighborhood sociodemographic characteristics and food store distributions in the Metropolitan Statistical Areas ({MSAs}) of 4 {US} cities (Birmingham, Alabama; Chicago, Illinois; Minneapolis, Minnesota; and San Francisco, California). We fitted a space-time Poisson regression model that accounted for the complex spatial-temporal correlation structure of store locations by introducing space-time random effects in an intrinsic conditionally autoregressive model within a Bayesian framework. After accounting for census tract–level area, population, their interaction, and spatial and temporal variability, census tract poverty was significantly and positively associated with increasing expected numbers of supermarkets among tracts in all 4 {MSAs}. A similar positive association was observed for convenience stores in Birmingham, Minneapolis, and San Francisco; in Chicago, a positive association was observed only for predominantly white and predominantly black tracts. Our findings suggest a positive association between greater numbers of food stores and higher neighborhood poverty, with implications for policy approaches related to food store access by neighborhood poverty.},
pages = {137--150},
number = {2},
journaltitle = {American Journal of Epidemiology},
shortjournal = {Am. J. Epidemiol.},
author = {Lamichhane, Archana P. and Warren, Joshua L. and Peterson, Marc and Rummo, Pasquale and Gordon-Larsen, Penny},
urldate = {2015-10-01},
date = {2015-01-15},
langid = {english},
pmid = {25515169},
keywords = {food availability, food stores, intrinsic conditionally autoregressive model, neighborhood characteristics, Poverty, sociodemographic factors, spatial-temporal modeling, supermarkets},
file = {complex_zotero_path}
}
但是,产生的输出显示为注释,而不是书目条目:
However, the produced output appears as comments, not as bibliographic entry:
使用以下代码编译文件:
The file is compiled with this code:
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS _paper.md --to latex
--from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
--output _paper.pdf --filter pandoc-citeproc --table-of-contents --toc-depth 2 --template "path_\latex\default.tex"
--number-sections --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in" --bibliography bibliography.bib
为简便起见,我将路径更改为_paper
和_paper
.
For brevity, I changed the paths to _paper
and _paper
.
当我尝试遵循关于在RStudio中包括书目的建议时,文档没有书目条目.因此,我的问题是在哪里出错,以及在RStudio中工作时如何强制生成书目条目?
When I tried to follow the advice on including bibliography in RStudio the document was produced with no bibliographic entries at all. Hence my question, where I'm making the mistake and how can I force generation of bibliographic entries when working in RStudio?
在非常有用的评论之后,理想情况下,我想避免在所附文档中明确指出引用的作品.事实上,我感兴趣的是包括一些参考书目,它将包括一些被引用的作品,以及与主要文档相关但在文档中未明确引用的论文.
Following very useful comments, ideally I would like to avoid explicitly indicating cited works in the attached document. As a matter of fact, I'm interested in including bibliography that will consist of some cited works but also papers that are relevant to the main document but are not explicitly referenced in the document.
推荐答案
pandoc文档说:
---
nocite: |
@item1, @item2
...
@item3
这篇关于在RMarkdown文档中使用参考书目将书目包括在内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!