David Díaz
David Díaz

Reputation: 171

Create a highchart for every dataset in R

I have three data, that I have been able to plot using highchart:

hchart(data1)
hchart(data2)
hchart(data3) 

Now what should I do if I want to have the three data in different plot but at the same page like this:like this

Upvotes: 1

Views: 467

Answers (3)

StupidWolf
StupidWolf

Reputation: 46888

You can use hw_grid as a quick fix if all of them have the same height:

library(htmltools)
library(highcharter)
h1 = hchart(prcomp(mtcars))
h2 = hchart(iris$Sepal.Width)
h3 = hchart(data.frame(x=1:10+runif(10),y=1:10+runif(10)),type="line")

combined = list(h1,h2,h3) %>% hw_grid(ncol=1,rowheight=250)
browsable(combined)

enter image description here

Or actually go down to using packages for combining htmlwidgets, where you can specify layout + row heights:

library(manipulateWidget)
combineWidgets(h1,h2,h3,ncol=1,rowsize=c(2,1,1))

enter image description here

Upvotes: 2

David Díaz
David Díaz

Reputation: 171

I figure it out with htmltools package:

library(htmltools)
browsable(
  tagList(
    hchart(data1),
    hchart(data2),
    hchart(data3)
  )
 )

It works fine for every html output, and can be configured.

Upvotes: 1

phago29
phago29

Reputation: 152

par function is what you need.

par(mfrow=c(3,1))
hchart(data1)
hchart(data2)
hchart(data3)

Upvotes: 0

Related Questions