1 bold <- function(x) {paste('{\\textbf{',x,'}}', sep ='')}
2 gray <- function(x) {paste('{\\textcolor{gray}{',x,'}}', sep ='')}
3 wrapify <- function (x) {paste("{", x, "}", sep="")}
5 # load("knitr_data.RData"); now broken up into small files so we'll bring 'em all in together
6 r <- do.call("c", lapply(paste("knitr_rdata/", list.files("knitr_rdata"), sep=""),
7 function (x) {load(x); return(r)}))
11 f <- function (x) {formatC(x, format="d", big.mark=',')}
13 format.percent <- function(x) {paste(f(x*100),"\\%",sep='')}
15 format.day.ordinal <- function(x) {
16 day <- format(x,format="%d")
17 daylast <- substr(day,nchar(day),nchar(day))
18 dayfirst <- substr(day,1,1)
23 day <- paste0(day,"st")
24 else if(daylast == "2")
25 day <- paste0(day,"nd")
26 else if (daylast == "3")
27 day <- paste0(day,"rd")
29 day <- paste0(day,"th")
34 format.month <- function(x){
35 return( format(x,format='%B %Y'))
38 format.date <- function(x) {
39 return(paste(format(x,format = '%B'),format.day.ordinal(x),format(x,format='%Y'),sep=' '))
42 format.pvalue <- function (x, digits=3) {
43 threshold <- 1*10^(-1*digits)
46 return(paste("p<", threshold, sep=""))
48 return(paste("p=", x, sep=""))