Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
knitr table and figure functions for Rmd
pasteLabel <- function(preText, inObj, objName, insLink=TRUE){
objNum <- inObj[objName]
useText <- paste(preText, objNum, sep=" ")
if (insLink){
useText <- paste("[", useText, "](#", objName, ")", sep="")
}
useText
}
# this increments the counter, and gives a name to the number so we can reference it later
incCount <- function(inObj, useName){
nObj <- length(inObj)
useNum <- max(inObj) + 1
inObj <- c(inObj, useNum)
names(inObj)[nObj+1] <- useName
inObj
}
figCount <- c("_"=0)
tableCount <- c("_"=0)
tableCat <- function(inFrame){
outText <- paste(names(inFrame), collapse=" | ")
outText <- c(outText, paste(rep("---", ncol(inFrame)), collapse=" | "))
invisible(apply(inFrame, 1, function(inRow){
outText <<- c(outText, paste(inRow, collapse=" | "))
}))
return(outText)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment