Add a title to a table created with reactable

Hi there! I created a table with the package reactable but i'am not sure how to add a title to it.
I have a few examples in Github where they add one, but i can't reach the same results.
This is my code:

library(reactable)
library(htmltools)
example<- reactable(data.frame(country=c("argentina","brazil"),
                     value=c(1,2)
                     ))
div(class = "table",
    div(class = "title", "Top CRAN Packages of 2019"),
    example
)
print(example)

This is an example where they add a title to a table among other things that i used to try to add my title:

Hello,

Your HTML will only render correctly if you knit it with markdown (See the example on the site)

For your code, it would look like this:

---
pagetitle: "Example"
output: html_document
---
```{r include=FALSE}
library(reactable)
library(htmltools)

myData = data.frame(country=c("argentina","brazil"),value=c(1,2))
                    
example<- reactable(
  myData,
  class = "example-tbl"
)

```


```{r echo=FALSE}
div(class = "example",
  div(class = "example-header",
      div(class = "example-title", "Top CRAN Packages of 2019"),
      example
  )
)
```

The names of the div() classes don't matter at this point as there is no custom CSS attached to this (in the example on the site there is)

Hope this helps,
PJ

Thank you! Now i understand. I will try to learn R Markdown.

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