I have a R markdown where I built a table and I want to add the option to download the table to a excel file.
kable(MyTable) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed",
"responsive")) %>%
scroll_box(width = "900px", height = "500px")
To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.
You can click in the upper left menu File > Import Dataset > From Excel and select the file to import it. Then you can copy the code that appears in the R console with the code required for import the data in xlsx and then copy it in a R Markdown code chunk.
To use it, open a Rmd document and, with the cursor within a r chunk and select “Addins –> Insert Table”.
Go to the Files tab in RStudio (lower right). Click Upload and browse to select the file you created. Then, use the read. csv() function to read in the file.
You could always try using DT::datatable
to get export buttons
MyTable %>%
DT::datatable(
extensions = 'Buttons',
options = list(dom = 'Bfrtip',
buttons = c('excel', "csv")))
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