I'm a new R user replicating a journal article that uses stata for its analysis. I am struggling to figure out how to generate similar code in R for one section of the code. The article is investigating the global spread of environmental ministries and in this section it examines the proportion of autocratic and democratic regimes that have established a national environmental ministry by years, I have provided one year as an example.
I've tried using functions in R such as if else () and indexing but I'm not sure I even understand the input of the stata code.
stata code:
democracies:
sum env_ministry_real if year == 1975 & polity2 >= 6 & polity2 != .
sum env_ministry_real if year == 1975 & polity2 >= 6 & polity2 != . & env_ministry_real == 1
di 10/36
autocracies:
sum env_ministry_real if year == 1975 & polity2 < 6 & polity2 != .
sum env_ministry_real if year == 1975 & polity2 < 6 & polity2 != . & env_ministry_real == 1
di 5/102
R code I've tried:
if (GSEM$year == 1975 & GSEM$polity2 >= 6) {
Democracies75 <- "Democ 1975"
} else if (GSEM$year == 1975 & GSEM$polity2 < 6) {
Autocracies75 <- "Autocrac 1975"
}
I expect to get the percentage proportion of democracies and autocracies that have established an environmental ministry in 1975.
Aucun commentaire:
Enregistrer un commentaire