Hello I have created a shiny app which creates the ggplot below but when Im trying to convert it to plotly with ggplotly() it does not respond. Anybody knows how to make the conversion?
output$energy_hour<-renderPlot({
# all levels
xlab <- seq(1, 24, 1/res)
xpos <- seq(1, 24*res, 1)
tab <- table(eny_subs()$energy, factor(eny_subs()$hour, levels=xlab))
tab <- prop.table(tab, margin=2)
barplot(tab, col=cols_energy, border="white", las=1, family="Corbel", ylab="aantal", xlab="uur", legend=TRUE,
main="energie per uur", ylim=range(pretty(c(0, colSums(tab))))
)
grid(nx=0, ny=NULL)
barplot(tab, col=cols_energy, border="white", las=1, family="Corbel", ylab="aantal", xlab="uur", legend=TRUE,
main="energie per uur", ylim=range(pretty(c(0, colSums(tab)))), add=TRUE
)
})
plotOutput("energy_hour")
Im using:
#################################### HOURS #####################################
output$energy_hour<-renderPlotly({
# all levels
xlab <- seq(1, 24, 1/res)
xpos <- seq(1, 24*res, 1)
tab <- table(eny_subs()$energy, factor(eny_subs()$hour, levels=xlab))
tab <- prop.table(tab, margin=2)
p1<- ggplot(tab, col=cols_energy, border="white", las=1, family="Corbel", ylab="aantal", xlab="uur", legend=TRUE,
main="energie per uur", ylim=range(pretty(c(0, colSums(tab))))
)
grid(nx=0, ny=NULL)
p1<- ggplot(tab, col=cols_energy, border="white", las=1, family="Corbel", ylab="aantal", xlab="uur", legend=TRUE,
main="energie per uur", ylim=range(pretty(c(0, colSums(tab)))), add=TRUE
)
ggplotly(p1)
})
plotlyOutput("energy_hour")
but I take: ggplot2 doesn't know how to deal with data of class table