Codes of the precious plot
library(plotly)
library(ggplot2)
age<-c(53,49,40,66,78,72,55,83,74,67,45,73,80,52,56,64,50,48,71,69)
year<-c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5,2, 3, 3, 3, 5, 5, 6, 7, 8, 8)
group<-c(rep('Control',10),rep('Treat',10))
life<-data.frame(cbind(age,year,group))
life$life_expectancy<-as.numeric(year)
life$age<-as.numeric(age)
life$all_life<-year+age
p1<-ggplot(data = life,aes(x=age,y=life_expectancy,color=group)) +
geom_point(size=4)
p2<-ggplot(data=life,aes(group,fill=group))+geom_bar()