I have a table where only some of the numbers should show digits after the decimal. I saw some examples in which formatC was used to convert the format in the dataframe before passing the data to knitr, but that aproach converts the values to character, and I need them to be numeric so I can specify the comma as the decimal separator.
Here is a minimal reproducible example:
---
title: "kble"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r global, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(shiny)
library(kableExtra)
library(janitor)
```
Title...
=====================================
Inputs {.sidebar data-width=400}
-------------------------------------
```{r cars}
x1 <- c("rojo","verde","azul","amarillo")
x2 <- c(30000,300,30.3,3.22)
df1<- data.frame(x1,x2)
df1%>%
knitr::kable(format.args = list(decimal.mark = ',', big.mark = "."),
caption = "Title",
align = "ccc"
)%>%
kable_styling("striped","hover",full_width = F)
```
I would like the "rojo" and "verde" rows to not have any decimal digits, and the "azul" and "amarillo" to keep them. Is there a way to achieve that? Thank you!