stefanedwards / lemon

🍋 Lemon --- Freshing up your ggplots
https://cran.r-project.org/package=lemon
GNU General Public License v3.0
180 stars 11 forks source link

lemon print and rounding of values #17

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello, I have a data.table with one column containing values of the order of 10e-10, when printing with lemon print the values are rounded to 0. I would need the actual values to be displayed. Is there a way to achieve that without touching the data.table? This how I do print

library(lemon)
knit_print.data.frame <- lemon_print

and in my chunk {r, render=lemon_print} I know I can do kable(df, digits = 10) but I was curious to know how to use the "digits" argument. Thank you

stefanedwards commented 4 years ago

Firstly, if you have overloaded the knit_print for a specific class, you don't have to specify the render argument in the chunks. I.e. with

knit_print.data.frame <- lemon_print

you no longer have to specify render=lemon_print when the resulting object is of that class.

Secondly, you can pass options to kable with with the kable.opts argument:

```{r, render=lemon_print,kable.opts=list(digits = 10)}
  data.frame or data.table or ...
```

Hope this helps!

ghost commented 4 years ago

Thank you it works perfectly :D