Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R markdown: download a html table to an excel file

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")
like image 255
JuanFerrer Avatar asked Dec 11 '18 16:12

JuanFerrer


People also ask

How do I export HTML from R markdown?

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.

How do I add an Excel table to R markdown?

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.

Can you insert a table into R markdown?

To use it, open a Rmd document and, with the cursor within a r chunk and select “Addins –> Insert Table”.

How do I import a CSV file into R markdown?

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.


1 Answers

You could always try using DT::datatable to get export buttons

MyTable %>%
  DT::datatable(
    extensions = 'Buttons', 
    options = list(dom = 'Bfrtip', 
                   buttons = c('excel', "csv")))
like image 113
Ross Dahlke Avatar answered Oct 18 '22 06:10

Ross Dahlke