Closed MrMisc closed 6 months ago
here is your problem you have repeated measures in your group_by. We need one value per group per year.
library(echarts4r)
library(tidyverse)
# Creating sample data for demonstration
Years <- sample(2000:2020, 942, replace = TRUE)
Sub_Continent <- sample(c("Africa", "Asia", "Europe", "North America", "South America"), 942, replace = TRUE)
Country <- sample(c("Country_A", "Country_B", "Country_C", "Country_D", "Country_E"), 942, replace = TRUE)
n <- sample(1:20, 942, replace = TRUE)
Cases <- sample(1:1000, 942, replace = TRUE)
Deaths <- sample(1:500, 942, replace = TRUE)
# Creating the tibble
eg <- tibble(Year = Years, Sub_Continent, Country, n, Cases, Deaths) |>
mutate(Year = as.Date(paste0(eg$Year, "-01-01")))
# here we have to make a choice because you have
#contradictory/repeated information in your data
df_unique <- eg |>
group_by(Sub_Continent, Year) |>
summarise(mean = mean(n)) # for example but you have too choose something
# you can also filter by country or take the max
#now everything works
plot <- df_unique |>
group_by(Sub_Continent) |>
e_charts(Year) |>
e_river(mean) |>
e_tooltip(trigger = "axis")
plot
Created on 2023-12-21 with reprex v2.0.2.9000
here is my buy me a coffee link if you feel like it
Thank you! I will be sure to double check my actual dataset and recall this!
I would like someone to help me understand, if possible, what makes river tick. I was under the impression that say I want to do time series, that I need to make sure that the column to be used for the x-axis be of Date format. However, my river plots often break and here is an MRE