2015-10-05 10 views
12

Ich versuche, knitcitations zu verwenden und Bibliographie zu dem R Markdown-Dokument, das ich in R Studio entwerfe, hinzuzufügen. Der Header meines Dokument sieht wie folgt aus:Including Bibliography in RMarkdown Dokument mit der Verwendung der Knochenkrankheiten

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

ich die Bibliographie am Ende mit dem folgenden Code hinzufügen möchten:

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

Die Referenzdatei bibliography.bib den folgenden Inhalt hat:

@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} 
} 
Die ausgegebene Ausgabe erscheint jedoch als Kommentar, nicht als bibliographischer Eintrag:

Die Datei wird mit diesem Code kompiliert:

"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 

Der Kürze halber ich die Pfade zu _paper und _paper geändert.


Als ich versuchte, die advice on including bibliography in RStudio das Dokument ohne bibliographische Einträge alle auf produziert wurde zu folgen. Daher meine Frage, wo mache ich den Fehler und wie kann ich die Generierung von bibliographischen Einträgen bei der Arbeit in RStudio erzwingen?

bearbeiten

sehr nützliche Kommentare Nach mag ich würde im Idealfall in dem beigefügten Dokument zitierten Arbeiten explizit vermeiden angibt. In der Tat bin ich daran interessiert, eine Bibliographie einzubeziehen, die aus einigen zitierten Werken bestehen wird, aber auch aus Artikeln, die für das Hauptdokument relevant sind, aber im Dokument nicht explizit erwähnt werden.

+1

Vielleicht müssen Sie 'csl' Datei auch liefern? – zx8754

+1

@ zx8754 mein Verständnis war, dass die 'csl' Datei nur im Falle von bestimmten Stil Anforderungen zur Verfügung gestellt wird. In diesem Moment möchte ich nur eine Liste relevanter Publikationen hinzufügen. Ich kann mit jedem referenzierenden Stil leben, sobald es den Lesern hilft, die relevante Arbeit zu finden. – Konrad

+0

Ja, du hast Recht 'csl' ist für den Format-Stil, sorry, ich bin noch auf meinen Baby-Schritten in der reproduzierbaren Forschungswelt. – zx8754

Antwort

11

Die pandoc documentation sagt:

Wenn Sie Einzelteile im Literaturverzeichnis aufnehmen möchten, ohne sie tatsächlich im Text zitiert, können Sie ein Dummy nocite Metadatenfeld definieren und die Zitate setzen dort:

--- 
nocite: | 
    @item1, @item2 
... 

@item3 

In diesem Beispiel ist die Dokument enthält nur ein Zitat für Artikel 3, aber die Bibliographie enthält Einträge für Artikel1, Artikel2 und Artikel3.

+0

Das ist was ich machen möchte, aber wo ist das "nocite: |" gehen? Ich habe es in meine Bibliographiedatei eingefügt, aber das hat nicht funktioniert und es scheint auch nicht in meinem Abschriften-Dokument zu funktionieren. Sind die 3 Striche an der Spitze notwendig? Und, gibt es etwas, das benötigt wird, um den Nocite-Abschnitt wie einen anderen vertikalen Balken zu schließen? Ich sehe, dass dies von der RStudio-Dokumentationsseite kopiert wird, aber ich konnte keine zusätzlichen Informationen dort finden, um meine Frage zu beantworten. – svannoy

11

Hier ist minimal Arbeitsbeispiel:

paper.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 

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

Konsolenausgabe

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 

Papier. pdf enter image description here

+0

Vielen Dank für das Interesse an meinem Beitrag und die Bereitstellung der Kommentare. Ist es wirklich notwendig, das '[@RCoreTeam] mit dem Shiny Framework [@ Chang2015]. Eigentlich möchte ich lediglich eine Bibliographie und keine Referenzliste anfügen. Es gibt einige Artikel, die für den Inhalt relevant sind, aber nicht direkt im Text erwähnt werden. Wenn dies der einzige Weg ist, kann ich immer den Satz umformulieren und die In-Text-Zitation einschließen, aber ich wäre viel glücklicher, wenn ich nur eine Liste der relevanten Werke anhängen würde. – Konrad

+1

@Konrad Jetzt sehe ich Ihr Problem, interessant, lohnt es, diesen Punkt zu Ihrem Beitrag hinzuzufügen. – zx8754

+2

@Konrad Ich denke, es muss im Text erwähnt werden, die Idee ist '.bib' Datei kann Hunderte von Referenzen haben, aber nur die in' .rmd' genannten Datei wird als Referenzen in PDF-Ausgabe kompiliert. – zx8754