Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Post template for bit.ly/FellBit
layout title tags categories
post
CHANGEME
CHANGEME
CHANGEME

{% include JB/setup %}

## Change if you want other options
require("knitr")
opts_chunk$set(fig.width=5, fig.height=5, cache=TRUE)

## Load knitcitations with a clean bibliography
library(knitcitations)
cleanbib()
cite_options(tooltip=TRUE)

## I made my own citing function since citep() doesn't work like I want to with
## urls that are not really pages themselves like part of a GitHub repo.
mycitep <- function(x, short=NULL, year=substr(date(), 21, 24), tooltip=TRUE) {
	res <- tmp <- citep(x)
	if(!is.null(short)) {
		res <- gsub("></a>", paste0(">", short, "</a>"), tmp)
	}		
	if(tooltip) {
		res <- gsub("\\?\\?\\?\\?", year, res)
	}
	res <- gsub("span> ", "span>", res)
	res
}

## Here's an example
# mycitep("https://github.com/lcolladotor/lcollado753", "Collado, 2013")
write.bibtex(c("knitcitations" = citation("knitcitations")), file = "pkgs.bib")
bib <- read.bibtex("pkgs.bib")

Start post

References

Citations made with knitcitations r mycitep(bib[["knitcitations"]], "Boettiger, 2013").

## Print bibliography
bibliography()

Reproducibility

sessionInfo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment