This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library(gapminder)
## Warning: package 'gapminder' was built under R version 4.0.3
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 4.0.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
data(gapminder, package = "gapminder")
gapminder<-data.frame(gapminder)
gg<-ggplot(gapminder, aes(gdpPercap, lifeExp, color = continent))+geom_point(aes(size = pop,frame=year, id=country))
## Warning: Ignoring unknown aesthetics: frame, id
ggplotly(gg)
library(ggplot2)
library(plotly)
dat <- data.frame(
time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(14.89, 17.23)
)
p <- ggplot(data=dat, aes(x=time, y=total_bill)) +
geom_bar(stat="identity")
fig <- ggplotly(p)
fig
Reference: https://plotly-r.com/animating-views.html https://towardsdatascience.com/create-animated-bar-charts-using-r-31d09e5841da