I have this data frame:
A_B2 <- data.frame(
Pais = c("Ecuador","ALC","OECD"),
Anio = c(rep(2014,each=9),rep(2017,each=9)),
value = c(12,13,3,11,18,44,1,2,3,11,12,3,12,17,49,1,2,3),
variable = c(rep("efectivo",each=3),rep("cuentaif",each=3),rep("telef",each=3)))
And with this code:
hchart(A_B2%>%filter(Anio=="2017"), "column", hcaes(x = Pais, y = value, group = variable), stack = "2017") %>%
hc_plotOptions(column = list(
dataLabels = list(enabled = FALSE),
stacking = "normal",
enableMouseTracking = TRUE))
But i want this chart; the variables stacked for each year with each "Pais".
I tried with this code with no result:
hchart(A_B2%>%filter(Anio=="2017"), "column", hcaes(x = Pais, y = value, group = variable), stack = "2017") %>%
hc_xAxis(categories = unique(A_B2$Pais)) %>%
hc_add_series(A_B2%>%filter(Anio=="2014"),type="column",hcaes(x = Pais, y = value, group = variable), stack = "2014")%>%
hc_plotOptions(column = list(
dataLabels = list(enabled = FALSE),
stacking = "normal",
enableMouseTracking = TRUE))
i found a similar question here wiht library(highcharter) enter link description here and with ggplot2 this would be the answer enter link description here
The solution with ggplot2 with my data would be:
ggplot(A_B2, aes(x = Pais, y = value, fill = variable)) + geom_col() + facet