To add a citation in Rmarkdown we can just type [@Author]
in the document. I wonder if it's possible to do this with R code.
The pseudo code for my expected solution:
# just markdown
This is my markdown content and here is a great book about it: `r insert_citation()`.
where insert_citation
is a function like this:
insert_citation <- function() "[@Author]"
This should produce the output like this (assuming I already prepared the bibliography for the document):
This is my markdown content and here is a great book about it: (A. Uthor 2021).
The point is that I need to add a citation conditionally based on data. If a condition is satisfied there should be the citation in the document, otherwise skip the citation. My document is a docx. Any hints related to officedown or officer packages are welcome.