# NOT RUN {
Format(as.Date(c("2014-11-28", "2014-1-2")), fmt="ddd, d mmmm yyyy")
Format(as.Date(c("2014-11-28", "2014-1-2")), fmt="ddd, d mmmm yyyy", lang="engl")
x <- pi * 10^(-10:10)
Format(x, digits=3, fmt="%", sci=NA)
Format(x, digits=4, sci=c(4, 6), leading = "drop", width=9, align=".")
# format a matrix
m <- matrix(runif(100), nrow=10,
dimnames=list(LETTERS[1:10], LETTERS[1:10]))
Format(m, digits=1)
# engineering format
Format(x, fmt="eng", digits=2)
Format(x, fmt="engabb", leading="00", digits=2)
# combine with grams [g]
paste(Format(x, fmt="engabb", leading="00", digits=2), "g", sep="")
# example form symnum
pval <- rev(sort(c(outer(1:6, 10^-(1:3)))))
noquote(cbind(Format(pval, fmt="p"), Format(pval, fmt="*")))
# use Fmt() to get and define new formats stored as option
Fmt() # all defined formats
Fmt("abs") # only format named "abs"
Fmt("nexist") # only format named "nexist" (nonexisting)
Fmt("abs", "per", "nexist")
Fmt("abs", digits=3) # get Fmt("abs") and overwrite digits
Fmt("abs", na.form="-") # get Fmt("abs") and add user defined na.form
# define totally new format and store as option
Fmt(nob=as.fmt(digits=10, na.form="nodat"))
# overwrite an existing format
Fmt(nob=Fmt("nob", digits=5))
Fmt("nob")
# change the character to be used as the decimal point
opt <- options(OutDec=",")
Format(1200, digits=2, big.mark = ".")
options(opt)
# }
Run the code above in your browser using DataLab