0

I have sample data for two datasets:

one <- data.frame(
  Timestamp = seq(from = as.POSIXct("2023-07-01"), by = "days", length.out = 5),
  `Heat Capacity` = c(10, 15, 8, 12, 20)
)


two <- data.frame(
  Timestamp = seq(from = as.POSIXct("2023-07-01"), by = "days", length.out = 3),
  `Heat Capacity` = c(8, 12, 6)
)

Without combining the two dataframes, can a line chart be formed using echarts4r?

I have done it using ggplot:

one_graph <- ggplot() +
  geom_line(data = one, aes(x = one[[1]], y = one[[2]])) +
  geom_line(data = two, aes(x = two[[1]], y = two[[2]])) 

Can the same be achieved using echarts4r?

Jan
  • 2,245
  • 1
  • 2
  • 16
Golem
  • 100
  • 9

1 Answers1

2

This is possible:

library(echarts4r)

one |> e_charts(Timestamp) |> 
    e_line(serie = Heat.Capacity) |> 
    e_data(data = two) |> 
    e_line(serie = Heat.Capacity)

enter image description here

Jan
  • 2,245
  • 1
  • 2
  • 16
  • I'm trying to plot data with lot of rows and I have doubt that which would be faster ggplot2 or echarts4r for plotting . When I use ggplot2 inside a shiny App it gives me a slight delay – Golem Jul 28 '23 at 12:45
  • You should ask a separate question for this. – Jan Jul 28 '23 at 15:43
  • 2
    (I guess you should accept this answer since it seems to do exactly what you asked for) – rdatasculptor Jul 29 '23 at 09:21