Skip to content
Prev 316333 / 398506 Next

Setting inline hook to a function identical to default in knitr turns of exponential formatting

This is a little bit hard to explain because there are two levels of
default hooks (the system default and the document-format-specific
default). The best way to explain it is probably the source code:
https://github.com/yihui/knitr/blob/master/R/output.R#L183-L189

In short, the "default" hooks you mentioned are not really used by
knitr at all; they are only placeholders in the system. If you do not
modify them in advance, knitr will set the appropriate hooks according
to the document format, e.g. the inline hook for LaTeX will use
scientific notation for numbers.

The absolute default inline hook does not do scientific notation, as
you can see from the its source:

## function (x)
## {
##    if (is.numeric(x))
##        x = round(x, getOption("digits"))
##    paste(as.character(x), collapse = ", ")
## }

I recommend you to ignore these system default hooks, unless you want
to study the technical implementation of this package. For the default
hooks according to the output format, see
http://yihui.name/knitr/hooks and ?render_latex in the documentation.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Mon, Jan 28, 2013 at 4:42 AM, mlell08 <mlell08 at gmail.com> wrote: