Created
September 9, 2018 13:52
-
-
Save diamonaj/97baf843a34ce108ad92f2a8e2c7ce7b to your computer and use it in GitHub Desktop.
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
| # A video accompanying this code is available (to those with Minerva Schools at KGI emails) here: | |
| # https://drive.google.com/file/d/17X9FTMDZdKKuSI0Amo93J0-QvcPgmeL5/view?usp=sharing | |
| rm(list = ls()) # clears working memory | |
| # To get the data | |
| # set the working directory | |
| setwd("~/Downloads") | |
| adbdata <- read.csv("Copy of datasetforCS112 - TA.csv") | |
| names(adbdata) | |
| # [1] "project.number" "status" "project.type" | |
| # [4] "approval.date" "implementation.start.date" "original.completion.date" | |
| # [7] "revised.completion.date" "project.budget" "cumulative.disbursements" | |
| # [10] "undisbursed.amount" "success.rating" | |
| # columns D through G (columns 4 through 7) are the date columns | |
| adbdata[, 4] <- as.Date(adbdata[, 4] - 25569, origin = as.Date('1970-01-01')) | |
| adbdata[, 5] <- as.Date(adbdata[, 5] - 25569, origin = as.Date('1970-01-01')) | |
| adbdata[, 6] <- as.Date(adbdata[, 6] - 25569, origin = as.Date('1970-01-01')) | |
| adbdata[, 7] <- as.Date(adbdata[, 7] - 25569, origin = as.Date('1970-01-01')) | |
| # exclude projects approved pre-1/1/1995 & post-1/1/2017 | |
| to_be_excluded <- which(adbdata$approval.date < as.Date("1995-01-01") & | |
| adbdata$approval.date > as.Date("1996-12-31")) | |
| adbdata <- adbdata[-to_be_excluded, ] | |
| # Here's a hint for durations (e.g., a project approved 01/01/95 and closed 12/31/95: | |
| as.numeric(as.Date("1995-12-31")) - as.numeric(as.Date("1995-01-01")) - | |
| # The command for histograms is hist(). You might want to Google it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment