How do I provide only the year in a citation in R markdown?
Asked Answered
R

1

15

My rmarkdown script looks as follows:

---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
  pdf_document: default
  bibliography: bibliography.bib
---

In his book Helsel explains how to approach censored environmental data [@helsel_statistics_2012].

MY .bib file as such:

@book{helsel_statistics_2012,
    address = {Hoboken, N.J},
    edition = {2nd ed},
    series = {Wiley series in statistics in practice},
    title = {Statistics for censored environmental data using {Minitab} and {R}},
    isbn = {978-0-470-47988-9},
    publisher = {Wiley},
    author = {Helsel, Dennis R.},
    year = {2012},
    note = {00003 OCLC: ocn748290711},
    keywords = {Environmental sciences, Measurement Statistical methods, Minitab, Pollution, R (Computer program language), Statistical methods},
}

When I knit the file I get the following output:

In his book Helsel explains how to approach censored environmental data (Helsel 2012).

Question: How can I return the year only in the in citation (as I already state the author in the text)?

In his book Helsel (2012) explains how to approach censored environmental data.

Rapping answered 18/8, 2017 at 13:32 Comment(0)
S
22

In the rmarkdown (.Rmd) file put the following (note the removal of [ ] brackets from [@helsel_statistics_2012]):

In his book @helsel_statistics_2012 explains how to approach censored environmental data.

Once rendered this will give you the desired output:

In his book Helsel (2012) explains how to approach censored environmental data.

If you really only want the year from the citation then:

[-@helsel_statistics_2012]

returns:

(2012)

For more details see the rmarkdown documetation on citations http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html

Swan answered 18/8, 2017 at 14:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.