Reputation: 126
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
?
Upvotes: 0
Views: 220
Reputation: 9348
This is possible:
library(echarts4r)
one |> e_charts(Timestamp) |>
e_line(serie = Heat.Capacity) |>
e_data(data = two) |>
e_line(serie = Heat.Capacity)
Upvotes: 2