R markdown to create tables in html and then save into power point or PDF

Hello,

Can someone advise me on how to create a table using R markdown / HTML
like the below format if I have a data frame with that data.

And then from the browser, html, R markdown save it into either power point or pdf.

Also I want to add images to the web page, can this be done.

Code example would be very helpful and appreciated it.

Capture

Hi, I guess that the simplest way is by using RStudio. I'd suggest to create a new R MarkDown document, and create (or load) your data in a dataframe. You're able to build nice tables by using this library kableExtra (interesting post here). Below a sample code. Once you've built your R Markdown you can then knit it as Html, Pdf or Word directly from R Studio.

---
title: "Test"
author: "Alessio Benedetti"
date: "30 marzo 2019"
output:
  pdf_document: default
  html_document: default
---

## Including Table

First we should a couple of libraries.

```{r libraries, echo=FALSE}
library(knitr)
library(kableExtra)

Then we can define a sample dataframe.

column1 <- c(1,2,3,4,5)
column2 <- c('hi', 'have', 'a', 'nice', 'day')
column3 <- c(TRUE, TRUE, FALSE, TRUE, FALSE)
df <- data.frame(column1, column2, column3) 

And finally we can display the sample table with a nice format!

df %>% kable() %>% kable_styling()
1 Like

Hi alessio,

Looks good.
How about if I wanted to format the tables in different ways like add colors to headers and the context of the table like the values - font color / font size etc. Can that be done too ? Thx for pointing me in the right direction. I will look into it more.

Well think you should take a look at this article. It states a good amount of table customizations :wink:

Great !!
I am excited.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.