Integration between R and HTML

Asked

Viewed 197 times

0

I would like to know how I export the results of a code in R to a panel developed in HTML?

  • Are they table data, numerical results, graphs? Put an example of what you need. Use Rstudio?

  • It would be to expose numerical results like Kpis and maybe some charts. The goal would be to generate an html Dashboard by obtaining data from calculations performed in R.

  • R would get the data from a database, do the calculations and Dashboard html would expose the results in the form of Kpis and graphs.

  • The simplest way would be to use the Rnotebook function in Rstudio. Otherwise, you need to organize your code as Rmarkdown, exporting the data of interest to html and hiding the unnecessary information in the view.

1 answer

3


You can make good dashboards with the package flexdashboard. I’ll put an example below, but of course you can do much more complex things, for example: https://gallery.shinyapps.io/cran-gauge/

First, install the package using

install.packages("flexdashboard")

Then run this here to create a file template.

rmarkdown::draft("dashboard.Rmd", template = "flex_dashboard", package = "flexdashboard")

It will create a file called dashboard.Rmd with a template code, well appreciated with the below. There you can put your code to generate the graphics the way you want.

For example:

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
plot(mtcars$disp, mtcars$drat)
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
plot(mtcars$qsec, mtcars$cyl)
```

### Chart C

```{r}
plot(mtcars$mpg, mtcars$drat)
```

Then press ctrl + shift + K or click the button knit in Rstudio. This will generate an html, like the below.

inserir a descrição da imagem aqui

You can configure almost anything. The documentation is pretty good. Read more here: http://rmarkdown.rstudio.com/flexdashboard/index.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.