I've tried looking at various places now and I can't figure out what the knit_hook$set function does exactly. I read the R documentation and it didn't really make much sense to me.
I'm trying to understand someone else's R code and there's a line at the beginning that's this
library(knitr)
knit_hooks$set(inline = function(x) { x = as.character(x) }
I searched the code and I couldn't find any other reference to inline, or a version of knit_hook$get. The R documentation says that it takes arguments and returns an output, which sounds exactly the same to me as a generic R function. I've searched online and it looks like some kind of functionality that automatically runs in a chunk of R code within a Sweave document?
I've looked through the other chunks of R code in the script I'm analyzing and I don't see anything that says "inline = True" which is what I expected to see after reading this: https://yihui.org/knitr/hooks/
I'm having a really difficult time understanding what this does. Could someone please explain the functionality and purpose of knit_hook$set with a more simple example?
Edit:This is direct text from the documentation I read
% small.mar does not have to be TRUE, it can be any non-null value
<<myplot, small.mar=TRUE>>= hist(rnorm(100), main = '') # no main title @
That's a line from the documentation I read that I linked above. The code I have does not have anything that says << inline = True>>=
Is it safe to assume if that's not there then this knit_hook$set is superflous then?
Also in the example above, where is the small.mar function being called? I don't see it being used anywhere, does it automatically get applied to the hist function in the example?