r - 使用 knititations 在 RMarkdown 文档中包含引用书目

标签 r latex r-markdown bibliography

我正在尝试使用 knititations 并将引用书目添加到我在 R Studio 中起草的 R Markdown 文档中。我的文档标题如下所示:

---
title: "Some Title"
author: "Me"
date: "September 2015"
bibliography: bibliography.bib
output:
  pdf_document: 
    highlight: tango
    number_sections: yes
    toc: yes
---

我想使用以下代码在末尾添加引用书目:

```{r generateBibliography, echo=FALSE, eval=TRUE, message=FALSE, warning=FALSE}
require("knitcitations")
cleanbib()
options("citation_format" = "pandoc")
read.bibtex(file = "bibliography.bib")
```

引用文件bibliography.bib具有以下内容:

@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}
}

但是,生成的输出显示为注释,而不是引用书目条目: sample entries

该文件是使用以下代码编译的:

"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

<小时/>

当我尝试遵循advice on including bibliography in RStudio时该文件的制作根本没有书目条目。因此我的问题是,我在哪里犯了错误,在 RStudio 中工作时如何强制生成书目条目?

编辑

以下非常有用的评论,理想情况下我想避免在附加文档中明确指出引用的作品。事实上,我感兴趣的是包含一些引用书目,其中包括一些引用的作品,但也包括与主要文档相关但未在文档中明确引用的论文。

最佳答案

这是最小的工作示例:

纸.Rmd

---
title: 'My Title'
author: "Me me me me!"
output: pdf_document
bibliography: references.bib
---

Application written in the R programming language [@RCoreTeam] using the Shiny framework [@Chang2015].

# REFERENCES

引用文献.bib

@Misc{Chang2015,
  Title                    = {shiny: Web Application Framework for R. R package version 0.12.1},

  Author                   = {Chang, W. and Cheng, J. and Allaire, JJ. and Xie, Y. and McPherson, J. },
  Year                     = {2015},

  Type                     = {Computer Program},
  Url                      = {http://CRAN.R-project.org/package=shiny}
}


@Article{RCoreTeam,
  Title                    = {R: A Language and Environment for Statistical Computing},
  Author                   = {{R Core Team}},
  Year                     = {2015},

  Type                     = {Journal Article},
  Url                      = {http://www.R-project.org}
}

控制台输出

processing file: paper.Rmd
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS paper.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output paper.pdf --filter pandoc-citeproc --template "C:\Users\tdadaev\Documents\R\win-library\3.2\rmarkdown\rmd\latex\default.tex" --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in" --bibliography references.bib 
output file: paper.knit.md


Output created: paper.pdf

论文.pdf enter image description here

关于r - 使用 knititations 在 RMarkdown 文档中包含引用书目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32946203/

相关文章:

r - 应用 tm 方法时一个变量的多个结果 "stemCompletion"

java - RNetLogo 可在 R3.1.1.0 上运行吗?

r - 在 R 中绘制具有级别的 netcdf 文件

linux - sed 将 "_"、 "&"、 "$"分别替换为 "\_"、 "\&"、 "\$"

r 中具有多个条件的数据重估

r - RMarkdown PDF 输出中未显示某些 Unicode 字符

latex - 如何使表格中的多行文本垂直居中

r-markdown - 在 Shiny 服务器上托管HTML页面

r - 如何使用 rmarkdown 添加引用

r - 如何在 Shiny 中包含带有反应式 MathJax 元素的 html 代码?