I have a code that works great, but I would lik it to be interractive.
The problem is when I apply ggplotly it dosent print on the html document.
This piece of code works great:
### ---- Display the sales graph (TW vs LY) ----
if (exists(division_cleaned, Lista_Graficos_Ventas_Por_Division)) {
grafico_division <- Lista_Graficos_Ventas_Por_Division[[division_cleaned]]$grafico
if (!is.null(grafico_division)) {
print(grafico_division)
} else {
cat("No graph available for this division.n")
}
}
But when I apply ggplotly like this it stops wotking:
### ---- Display the sales graph (TW vs LY) ----
if (exists(division_cleaned, Lista_Graficos_Ventas_Por_Division)) {
grafico_division <- Lista_Graficos_Ventas_Por_Division[[division_cleaned]]$grafico
if (!is.null(grafico_division)) {
# Convertir el gráfico ggplot2 en un objeto plotly para interactividad
ggplotly(grafico_division)
} else {
cat("No graph available for this division.n")
}
}
May be its because im in a rmarkdown loop?