#y="Physical activity",x="Outside air pollution"
plot_ly(data_country,x=~log10(Outdoor.air.pollution),y=~Low.physical.activity,color=~develop,frame=~Year,
hoverinfo = "text",type = 'scatter',mode = 'markers',
text = ~develop,size=~Air.pollution)
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
###value of Household.air.pollution.from.solid.fuels
accumulate_by <- function(dat, var) {
var <- lazyeval::f_eval(var, dat)
lvls <- plotly:::getLevels(var)
dats <- lapply(seq_along(lvls), function(x) {
cbind(dat[var %in% lvls[seq(1, x)], ], frame = lvls[[x]])
})
dplyr::bind_rows(dats)
}
plotData <- data_world %>% accumulate_by(~Year )
plotData$variable <- as.character(plotData$Household.air.pollution.from.solid.fuels)
plotData$frame <- as.character(plotData$frame)
p <- ggplot(plotData , aes(x = Year,y = Household.air.pollution.from.solid.fuels, colour = Entity , frame = frame))+
geom_line()
ggplotly(
p = p,
width = NULL,
height = NULL,
dynamicTicks = FALSE,
layerData = 1,
originalData = TRUE) %>%
animation_opts(frame = 300, transition = 0, easing = "linear", redraw = TRUE)
#different Year
#factors:High.systolic.blood.pressure, Smoking,Air.pollution, Alcohol.use, Diet.high.in.sodium, Unsafe.water.source,
# develop
data_country_plot <- data_country[,.(High.systolic.blood.pressure = mean(High.systolic.blood.pressure)
,Smoking = mean(Smoking)
,Air.pollution = mean(Air.pollution)
,Alcohol.use = mean(Alcohol.use)
,Diet.high.in.sodium = mean(Diet.high.in.sodium)
,Unsafe.water.source = mean(Unsafe.water.source )
)
,.(Year ,develop)]
blood <- ggplot(data_country_plot,
aes(x =Year ,y = High.systolic.blood.pressure,color = develop ))+
geom_line()
ggplotly(blood)
smoking <- ggplot(data_country_plot,
aes(x =Year ,y = Smoking,color = develop ))+
geom_line()
ggplotly(smoking)
pollution <- ggplot(data_country_plot,
aes(x =Year ,y = Air.pollution ,color = develop ))+
geom_line()
ggplotly(pollution)
alcohol <- ggplot(data_country_plot,
aes(x =Year ,y =Alcohol.use ,color = develop ))+
geom_line()
ggplotly(alcohol)