Created
June 30, 2017 11:45
-
-
Save vikjam/543dcf783fa6b515192a2ca5bd10a336 to your computer and use it in GitHub Desktop.
Quick comparison of locus of control by debt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(foreign) | |
| library(dplyr) | |
| library(ggplot2) | |
| success <- read.dta("ALP_MS118_2016_03_13_06_51_42.dta") | |
| scpc2010 <- read.dta("SCPC2010.dta") | |
| scpc2010.adopt <- scpc2010[ , c("prim_key", "cc_adopt", "cc_sh")] | |
| success.locus <- success[ , c("ms118_prim_key", "ms118_lc1")] | |
| names(success.locus) <- c("prim_key", "locus") | |
| merged <- full_join(success.locus, scpc2010.adopt, by = "prim_key") | |
| g <- ggplot(merged, aes(x = locus, y = cc_adopt)) | |
| p <- g + stat_summary(fun.data = "mean_se", na.rm = TRUE) + | |
| xlab("I believe the way I manage my money will affect my future.") + | |
| ylab("Fraction with credit card") | |
| ggsave(p, file = "locus-cc_adopt.png") | |
| g <- ggplot(merged, aes(x = locus, y = cc_sh)) | |
| p <- g + stat_summary(fun.data = "mean_se", na.rm = TRUE) + | |
| xlab("I believe the way I manage my money will affect my future.") + | |
| ylab("Share of payments made with credit card") | |
| ggsave(p, file = "locus-cc_sh.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment