library(haven)
master_data_clean <- read_dta("G:/replication/output/master-data-clean.dta")
library(tidyverse)
library(psych)
#>
#> Attaching package: 'psych'
#> The following objects are masked from 'package:ggplot2':
#>
#> %+%, alpha
data7= master_data_clean %>%
select(c("latrine", "mboy", "mgirl", "wealth", "hhsize", "agehead", "educhead", "boys", "girls", "sexratio", "haryana", "post","year"))
data7= as.data.frame(data7)
data8= as.data.frame( subset(data7, data7$haryana==1 & data7$post==0))
describe_data8=describe(data8, skew = FALSE, ranges = FALSE, IQR = FALSE)
describe_data8= as.data.frame(describe_data8)
data9= as.data.frame( subset(data7, data7$haryana==1 & data7$post==1))
describe_data9=describe(data9, skew = FALSE, ranges = FALSE, IQR = FALSE)
describe_data9= as.data.frame(describe_data9)
data10= as.data.frame( subset(data7, data7$haryana==0 & data7$post==0))
describe_data10=describe(data10, skew = FALSE, ranges = FALSE, IQR = FALSE)
describe_data10= as.data.frame(describe_data10)
data11= as.data.frame( subset(data7, data7$haryana==0 & data7$post==1))
describe_data11=describe(data11, skew = FALSE, ranges = FALSE, IQR = FALSE)
describe_data11= as.data.frame(describe_data11)
data_meta1= cbind(describe_data8[,3], describe_data9[,3], describe_data10[,3], describe_data11[,3])
colnames(data_meta1)= c("haryana2004", "harayana2008", "control 2004", "control2008")
rownames(data_meta1)= c("latrine", "mboy", "mgirl", "wealth", "hhsize", "agehead", "educhead",
"boys", "girls", "sexratio", "haryana", "post","year")
data_meta1= t(data_meta1)
data_meta1= as.data.frame(data_meta1)
data_meta1[,14]= c("haryana", "haryana", "control", "control")
data_meta1[,15]= c(2004,2008,2004,2008)
data_meta1[1:2, 16]= c(1,1)
data_meta1[3:4, 16]= c(2,2)
data_meta1[,17]= c("haryana_wealth", "haryana_wealth", "control_wealth", "control_wealth")
data_meta1[,18]= c("haryana_educhead", "haryana_educhead", "control_educhead", "control_educhead")
data_meta1= as.data.frame(data_meta1)
colnames(data_meta1)= c("latrine", "mboy", "mgirl", "wealth", "hhsize", "agehead", "educhead", "boys", "girls",
"sexratio", "haryana", "post","year", "haryana2_latrine", "year2", "new",
"haryana2_wealth", "haryana2_educhead")
data_meta1= as.data.frame(data_meta1)
library(ggplot2)
library(gganimate)
theme_set(theme_bw())
p2 <- ggplot(data_meta1, aes(as.numeric(year), frame = year2)) +
geom_point(aes(y= latrine, color = as.factor( haryana2_latrine), size= latrine)) +
geom_line(aes(y= latrine, group=as.factor(new), color = as.factor( haryana2_latrine)))+
geom_point(aes(y= wealth, color = as.factor( haryana2_wealth), size=wealth)) +
geom_line(aes(y= wealth, group=as.factor(new), color = as.factor( haryana2_wealth)))+
geom_point(aes(y= educhead, color = as.factor( haryana2_educhead), size= educhead)) +
geom_line(aes(y= educhead, group=as.factor(new), color = as.factor( haryana2_educhead)))
# Notice we added frame = year and saved the plot as p.
# We then display it as an animation with the gg_animate function:
gganimate(p2)
#> geom_path: Each group consists of only one observation. Do you need to
#> adjust the group aesthetic?
#> geom_path: Each group consists of only one observation. Do you need to
#> adjust the group aesthetic?
#> geom_path: Each group consists of only one observation. Do you need to
#> adjust the group aesthetic?
#> geom_path: Each group consists of only one observation. Do you need to
#> adjust the group aesthetic?
#> geom_path: Each group consists of only one observation. Do you need to
#> adjust the group aesthetic?
#> geom_path: Each group consists of only one observation. Do you need to
#> adjust the group aesthetic?
library(tweenr)
data1= tween_elements(data_meta1, time = "year", group = "new", ease = "linear")
#> Error in col2rgb(d): invalid color name 'haryana'
Created on 2018-04-10 by the reprex package (v0.2.0).