Reputation: 61
I'm using this code to generate 2 highchart objects with rmarkdown:
---
title: "Untitled"
output: html_document
---
```{r library_objects, include= FALSE, echo = FALSE}
library(highcharter)
```
```{r objects, include = T, echo = FALSE}
df1 <- data.frame(data = c(2, 4, 6, 10),
labels = c("A", "B", "C", "D")
)
df2 <- data.frame(data = c(1, 3, 5, 9),
labels = c("Z", "Y", "X", "W")
)
```
```{r charts, include = T, echo = FALSE}
highchart(height = 150, width = 750) %>%
hc_add_series(data = df1$data) %>%
hc_xAxis(categories = df1$labels)
highchart(height = 150, width = 750) %>%
hc_add_series(data = df2$data) %>%
hc_xAxis(categories = df2$labels)
```
How could I manage to show them at the same horizontal level (one at the left and the other at the right side)?
Upvotes: 2
Views: 1097
Reputation: 3029
In highcharter package there is hw_grid
function.
```{r charts, include = T, echo = FALSE}
h1 <- hchart(rnorm(100))
h2 <- hchart(sample(head(letters), size = 100, prob = 1:6, replace = TRUE))
hw_grid(h1, h2)
```
There are some other packages to make grid of htmlwidgets like trelliscope. Maybe you want to check them.
Upvotes: 3