Say I have the following object inside a knitr chunk:
df <- as.Date(c("2013-10-01", "2013-10-02", "2013-10-03"))
Now, when I try to run this:
`r min(df)` # that would be \Sexpr{min(df)} for a TeX file
I get the following error:
Error in Math.Date(x) : abs not defined for "Date" objects
Calls: knit ... .inline.hook -> format_sci -> vapply -> FUN -> Math.Date
Execution halted
knitr terminated with status 1
Is this a bug? How can I work around it?
I don't know if this will qualify as an answer, but yes, that does seem to be a bug--I wonder what other classes are affected!
A simple but possibly inconvenient workaround would be to convert your output to "character" first. In other words, try something like:
```{r} df <- as.Date(c("2013-10-01", "2013-10-02", "2013-10-03")) ``` Here's a paragraph with `r as.character(min(df))`.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With