Skip to content

Instantly share code, notes, and snippets.

@Aaronmoralesshildrick
Created September 20, 2018 11:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Aaronmoralesshildrick/657a185e1c2971b7003b97875d8a3980 to your computer and use it in GitHub Desktop.
CS112 Assignment 1 Code
# Morales is my surname so, M = 13, O = 15, R = 18.
#Leads to us perfomring the code with said seed
#Using the second digit of each we arrive at 358 as a number.
set.seed(358)
my_questions_are_these <- sort(sample(c(1:10), 3, replace = FALSE))
my_questions_are_these
#answer to this is: 4, 9, 10
mydata <- read.csv("/Users/aaron/Downloads/AarondatasetforCS112\ -\ TA.csv")
mydata[, 4] <- as.Date(mydata[, 4] - 25569, origin = as.Date('1970-01-01'))
mydata[, 5] <- as.Date(mydata[, 5] - 25569, origin = as.Date('1970-01-01'))
mydata[, 6] <- as.Date(mydata[, 6] - 25569, origin = as.Date('1970-01-01'))
mydata[, 7] <- as.Date(mydata[, 7] - 25569, origin = as.Date('1970-01-01'))
class(mydata$approval.date)
class(mydata$implementation.start.date)
class(mydata$original.completion.date)
class(mydata$revised.completion.date)
summary(mydata)
excluded_dates <- which(mydata$approval.date < as.Date("1995-01-01") |
mydata$approval.date > as.Date("2017-01-01"))
mydatasubset <- mydata[-excluded_dates, ]
summary(mydatasubset)
#question 4
excluded_dates95 <- which(mydatasubset$approval.date < as.Date("1995-01-01") |
mydatasubset$approval.date > as.Date("1995-12-31"))
year95 <- mydatasubset[-excluded_dates95, ]
excluded_dates96 <- which(mydatasubset$approval.date < as.Date("1996-01-01") |
mydatasubset$approval.date > as.Date("1996-12-31"))
year96 <- mydatasubset[-excluded_dates96, ]
excluded_dates97 <- which(mydatasubset$approval.date < as.Date("1997-01-01") |
mydatasubset$approval.date > as.Date("1997-12-31"))
year97 <- mydatasubset[-excluded_dates97, ]
excluded_dates98 <- which(mydatasubset$approval.date < as.Date("1998-01-01") |
mydatasubset$approval.date > as.Date("1998-12-31"))
year98 <- mydatasubset[-excluded_dates98, ]
excluded_dates99 <- which(mydatasubset$approval.date < as.Date("1999-01-01") |
mydatasubset$approval.date > as.Date("1999-12-31"))
year99 <- mydatasubset[-excluded_dates99, ]
excluded_dates00 <- which(mydatasubset$approval.date < as.Date("2000-01-01") |
mydatasubset$approval.date > as.Date("2000-12-31"))
year00 <- mydatasubset[-excluded_dates00, ]
excluded_dates01 <- which(mydatasubset$approval.date < as.Date("2001-01-01") |
mydatasubset$approval.date > as.Date("2001-12-31"))
year01 <- mydatasubset[-excluded_dates01, ]
excluded_dates02 <- which(mydatasubset$approval.date < as.Date("2002-01-01") |
mydatasubset$approval.date > as.Date("2002-12-31"))
year02 <- mydatasubset[-excluded_dates02, ]
excluded_dates03 <- which(mydatasubset$approval.date < as.Date("2003-01-01") |
mydatasubset$approval.date > as.Date("2003-12-31"))
year03 <- mydatasubset[-excluded_dates03, ]
excluded_dates04 <- which(mydatasubset$approval.date < as.Date("2004-01-01") |
mydatasubset$approval.date > as.Date("2004-12-31"))
year04 <- mydatasubset[-excluded_dates04, ]
excluded_dates05 <- which(mydatasubset$approval.date < as.Date("2005-01-01") |
mydatasubset$approval.date > as.Date("2005-12-31"))
year05 <- mydatasubset[-excluded_dates05, ]
excluded_dates06 <- which(mydatasubset$approval.date < as.Date("2006-01-01") |
mydatasubset$approval.date > as.Date("2006-12-31"))
year06 <- mydatasubset[-excluded_dates06, ]
excluded_dates07 <- which(mydatasubset$approval.date < as.Date("2007-01-01") |
mydatasubset$approval.date > as.Date("2007-12-31"))
year07 <- mydatasubset[-excluded_dates07, ]
excluded_dates08 <- which(mydatasubset$approval.date < as.Date("2008-01-01") |
mydatasubset$approval.date > as.Date("2008-12-31"))
year08 <- mydatasubset[-excluded_dates08, ]
excluded_dates09 <- which(mydatasubset$approval.date < as.Date("2009-01-01") |
mydatasubset$approval.date > as.Date("2009-12-31"))
year09 <- mydatasubset[-excluded_dates09, ]
excluded_dates10 <- which(mydatasubset$approval.date < as.Date("2010-01-01") |
mydatasubset$approval.date > as.Date("2010-12-31"))
year10 <- mydatasubset[-excluded_dates10, ]
excluded_dates11 <- which(mydatasubset$approval.date < as.Date("2011-01-01") |
mydatasubset$approval.date > as.Date("2011-12-31"))
year11 <- mydatasubset[-excluded_dates11, ]
excluded_dates12 <- which(mydatasubset$approval.date < as.Date("2012-01-01") |
mydatasubset$approval.date > as.Date("2012-12-31"))
year12 <- mydatasubset[-excluded_dates12, ]
excluded_dates13 <- which(mydatasubset$approval.date < as.Date("2013-01-01") |
mydatasubset$approval.date > as.Date("2013-12-31"))
year13 <- mydatasubset[-excluded_dates13, ]
excluded_dates14 <- which(mydatasubset$approval.date < as.Date("2014-01-01") |
mydatasubset$approval.date > as.Date("2014-12-31"))
year14 <- mydatasubset[-excluded_dates14, ]
excluded_dates15 <- which(mydatasubset$approval.date < as.Date("2015-01-01") |
mydatasubset$approval.date > as.Date("2015-12-31"))
year15 <- mydatasubset[-excluded_dates15, ]
excluded_dates16 <- which(mydatasubset$approval.date < as.Date("2016-01-01") |
mydatasubset$approval.date > as.Date("2016-12-31"))
year16 <- mydatasubset[-excluded_dates16, ]
dim(year95)
dim(year96)
dim(year97)
dim(year98)
dim(year99)
dim(year00)
dim(year01)
dim(year02)
dim(year03)
dim(year04)
dim(year05)
dim(year06)
dim(year07)
dim(year08)
dim(year09)
dim(year10)
dim(year11)
dim(year12)
dim(year13)
dim(year14)
dim(year15)
dim(year16)
totaldims <- c(48, 51, 52, 230, 307, 295, 252, 315, 307, 305, 269, 233, 198,
251, 267, 285, 275, 270, 298, 256, 195, 225)
mean(totaldims)
#average is 236
#Question 9
assessed <- c(mydatasubset$success.rating)
which(assessed == 1|0)
summary(assessed)
summary(mydatasubset$success.rating)
#2455 NA's. This means that this is the number of unassigned projects out of 5184
#2455/5184 = 47.357%
#Question 10
summary(year95$success.rating)
summary(year96$success.rating)
summary(year97$success.rating)
summary(year98$success.rating)
summary(year99$success.rating)
summary(year00$success.rating)
summary(year01$success.rating)
summary(year02$success.rating)
summary(year03$success.rating)
summary(year04$success.rating)
summary(year05$success.rating)
summary(year06$success.rating)
summary(year07$success.rating)
summary(year08$success.rating)
summary(year09$success.rating)
summary(year10$success.rating)
summary(year11$success.rating)
summary(year12$success.rating)
summary(year13$success.rating)
summary(year14$success.rating)
summary(year15$success.rating)
summary(year16$success.rating)
head(year95)
NAs <- c(17, 16, 19, 101, 125, 127, 105, 135, 120, 108,
105, 79, 70, 95, 103, 92, 108, 123, 193, 202, 188, 224)
#Plotting the line graph
Years <- c(1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016)
Ratio <- round(1 - (NAs/totaldims), digits = 3)
lineplot = data.frame(Years, Ratio)
#plot(x, yearlyratio)
library(ggvis)
lineplot %>% ggvis(~Years, ~Ratio) %>% layer_lines()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment