Guest User

Untitled

a guest
Apr 22nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.83 KB | None | 0 0
  1. iter <- 19
  2. for (d in c(3,4)){
  3. for (n in c(1,3,10)){
  4. for (k in c(.1, .3, .6)){
  5. library(RMySQL)
  6. library(DBI)
  7. library(partitions)
  8. library(igraph)
  9. library(pbapply)
  10. ########################################### Population and Database initialization ###################################
  11. load("listDf_Final.rda") #Loads into object "listDf" of all contacts and base transmission probabilities for each individual as a list of data frames
  12. #Database Connection
  13. #con <- dbConnect(MySQL(), user="g1081391", password="Wif1hasnomeaning", dbname="g1081391", host="mydb.ics.purdue.edu")
  14. #on.exit(dbDisconnect(con))
  15.  
  16. con <- dbConnect(MySQL(), user="g1081391", password="Wif1hasnomeaning", dbname="g1081391", host="mydb.ics.purdue.edu")
  17. on.exit(dbDisconnect(con))
  18.  
  19. ################################################# Queries ###############################################
  20.  
  21. QEnd <- ") ORDER BY RAND() LIMIT " #ending query fragment to pull out only poisson # of contacts
  22.  
  23. # Select a poisson number of random Person_ID who belong to same ____ as our infected indiv
  24. QWork <- "SELECT I.Person_ID AS Person_ID
  25. FROM Individuals I, Works_At W
  26. WHERE I.Person_ID = W.Person_ID AND W.Work_ID = (SELECT W.Work_ID
  27. FROM Works_At W
  28. WHERE W.Person_ID = "
  29.  
  30. QCommunity <- "SELECT I.Person_ID AS Person_ID
  31. FROM Individuals I, Household H
  32. WHERE I.Household_ID = H.Household_ID AND H.Region_Num = (SELECT H.Region_Num
  33. FROM Individuals I, Household H
  34. WHERE I.Household_ID = H.Household_ID
  35. AND I.Person_ID = "
  36.  
  37. QDensity <- "SELECT R.Pop_Density
  38. FROM Individuals I, Household H, Region R
  39. WHERE I.Household_ID = H.Household_ID AND H.Region_Num = R.Region_Num
  40. AND I.Person_ID = "
  41.  
  42. QAvgDensity <- "SELECT AVG(Pop_Density)
  43. FROM Region;"
  44.  
  45. QBus <- "SELECT DISTINCT I.Person_ID AS Person_ID
  46. FROM Individuals I, Household H, Bus_Routes B
  47. WHERE I.Household_ID = H.Household_ID AND H.Region_Num = B.Region_Num AND H.PubTrans = 'YES' AND B.Bus_ID IN (SELECT DISTINCT B.Bus_ID
  48. FROM Individuals I, Household H, Bus_Routes B
  49. WHERE I.Household_ID = H.Household_ID AND H.Region_Num = B.Region_Num AND H.PubTrans = 'YES' AND I.Person_ID = "
  50.  
  51. QHousehold <- "SELECT I.Person_ID AS Person_ID
  52. FROM Individuals I
  53. WHERE I.Household_ID = (SELECT I.Household_ID
  54. FROM Individuals I
  55. WHERE I.Person_ID = "
  56.  
  57. #Multiplier Queries (Attributes of Individuals)
  58.  
  59. QWhite <- "SELECT I.Person_ID AS WhiteID
  60. FROM Individuals I, Household H
  61. WHERE I.Household_ID = H.Household_ID AND H.Race = 'White';"
  62.  
  63. QAsian <- "SELECT I.Person_ID AS AsianID
  64. FROM Individuals I, Household H
  65. WHERE I.Household_ID = H.Household_ID AND H.Race = 'Asian';"
  66.  
  67. QBlack <- "SELECT I.Person_ID AS BlackID
  68. FROM Individuals I, Household H
  69. WHERE I.Household_ID = H.Household_ID AND H.Race = 'Black';"
  70.  
  71. QHispanic <- "SELECT I.Person_ID AS HispanicID
  72. FROM Individuals I, Household H
  73. WHERE I.Household_ID = H.Household_ID AND H.Race = 'Hispanic';"
  74.  
  75. QMultirace <- "SELECT I.Person_ID AS MultiraceID
  76. FROM Individuals I, Household H
  77. WHERE I.Household_ID = H.Household_ID AND H.Race = 'Multirace';"
  78.  
  79. QAmerIndian <- "SELECT I.Person_ID AS AmerIndianID
  80. FROM Individuals I, Household H
  81. WHERE I.Household_ID = H.Household_ID AND H.Race = 'Amer Indian';"
  82.  
  83. QPov <- "SELECT I.Person_ID AS povID
  84. FROM Individuals I, Household H
  85. WHERE I.Household_ID = H.Household_ID AND H.Income < 10000;"
  86.  
  87. Qinfant <- "SELECT I.Person_ID AS infantID
  88. FROM Individuals I
  89. WHERE FLOOR(DATEDIFF(CURDATE(),I.DOB) / 365.25) <= 4;"
  90.  
  91. Qchild <- "SELECT I.Person_ID AS childID
  92. FROM Individuals I
  93. WHERE FLOOR(DATEDIFF(CURDATE(),I.DOB) / 365.25) BETWEEN 5 AND 18;"
  94.  
  95. Qadult <- "SELECT I.Person_ID AS adultID
  96. FROM Individuals I
  97. WHERE FLOOR(DATEDIFF(CURDATE(),I.DOB) / 365.25) BETWEEN 19 AND 64;"
  98.  
  99. Qsenior <- "SELECT I.Person_ID AS seniorID
  100. FROM Individuals I
  101. WHERE FLOOR(DATEDIFF(CURDATE(),I.DOB) / 365.25) > 64;;"
  102.  
  103. #Decide who to infect! and how many!
  104. Qinf_IDs <- "SELECT I.Person_ID AS ID
  105. FROM Individuals I
  106. ORDER BY RAND()
  107. LIMIT "
  108. ########################################### Parameter intialization ###############################
  109. popSize <- 140632
  110. pop <- data.frame(ID = c(1:popSize)) #individual IDs as a column
  111. duration <- 100 #number of days for simulation
  112. meanContactsDay <- 13.4 #https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2270306/
  113. meanDensity <- dbGetQuery(con, QAvgDensity) #mean density of all regions
  114.  
  115. ##############################################User inputs##############################################
  116. diseaseType <- d #Enter type of disease 1= Influenza, 2 = Smallpox, 3 = Measles, 4 = Ebola
  117. #Initial infected individuals ID by query
  118. initialNumber <- n #1, 3, or 10
  119. kPct <- k#k nodes percentage to identify 0.1, 0.3, 0.6
  120. ####################################################################################################################
  121.  
  122. #variable declarations+ initialization:
  123. tempdf <- dbGetQuery(con, paste0(Qinf_IDs,initialNumber))
  124. inf_IDs <- tempdf$ID
  125. totalPeople <- length(pop$ID) #total number of people
  126. numInfected <- rep(length(inf_IDs),1)
  127. numRecovered <- rep(0,1)
  128. numDead <- rep(0,1)
  129. susceptible <- rep((totalPeople - length(inf_IDs)),1)
  130. nextInf_IDs <- vector()
  131. cumDead_ID <- vector()
  132. cumRecov_ID <- vector()
  133. totalEdges <- data.frame(ID1 = inf_IDs, ID2 = NA) #initialize for all contacts in sim
  134.  
  135. #Disease Rate
  136. avgMult <- mean(c(1,1,2.4,6)) #taken from plot of disease contagiousness
  137. contagious <- 1/avgMult
  138. ifelse(diseaseType == 2, contagious <- 2.4/avgMult,
  139. ifelse(diseaseType == 3, contagious <- 6/avgMult, contagious <- 1/avgMult)) #contagious multiplier for disease type
  140.  
  141. #Normalized to White multipliers for each race to infectious disease (CDC)
  142. raceMean <- mean(c(3.0,8.1,10.9,8.2,4.1,100))
  143. raceWeight <- c(8.1/raceMean, 10.9/raceMean, 8.2/raceMean, 4.1/raceMean,4.1/raceMean) #asian, black, hispanic, amerindian, multirace
  144.  
  145. povWeight <- 1.5 #No exact multiplier can be found, but two biosecurity papers suggest strong correlations between poverty and influenza
  146.  
  147. #Age weight: 0-4, 5-18, 19-64, > 65
  148. ageWeight <- c(0.0005775, 0.000575, 0.0003175, 0.000855)#transmission weight based on age and seasonal influenza
  149. #Data taken from summing the columns of the transition probability matrix from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2725959/
  150. deathRate <- c(0.00005, 0.00003, 0.001,0.027) #for each age group: 0-4, 5-18, 19-64, > 65 for influenza
  151. RecoveryRate <- 1/6 #rate = 1/ average time spent in infected class
  152.  
  153. #Produces logical vectors of Individual IDs of different demographics
  154. whiteID <- dbGetQuery(con, QWhite)
  155. asianID <- dbGetQuery(con, QAsian)
  156. blackID <- dbGetQuery(con, QBlack)
  157. hispanicID <- dbGetQuery(con, QHispanic)
  158. multiraceID <- dbGetQuery(con, QMultirace)
  159. amerindianID <- dbGetQuery(con, QAmerIndian)
  160. povID <- dbGetQuery(con, QPov)
  161. infantID <- dbGetQuery(con, Qinfant)
  162. childID <- dbGetQuery(con, Qchild)
  163. adultID <- dbGetQuery(con, Qadult)
  164. seniorID <- dbGetQuery(con, Qsenior)
  165.  
  166. #Population characteristics into pop dataframe
  167. pop$Race[pop$ID %in% whiteID$WhiteID] <- "White"
  168. pop$Race[pop$ID %in% asianID$AsianID] <- "Asian"
  169. pop$Race[pop$ID %in% blackID$BlackID] <- "Black"
  170. pop$Race[pop$ID %in% hispanicID$HispanicID] <- "Hispanic"
  171. pop$Race[pop$ID %in% multiraceID$MultiraceID] <- "Multirace"
  172. pop$Race[pop$ID %in% amerindianID$AmerIndianID] <- "American Indian"
  173. pop$Race[pop$ID %in% asianID$AsianID] <- "Asian"
  174. age <- dbGetQuery(con, "SELECT FLOOR(DATEDIFF(CURDATE(),I.DOB) / 365.25) AS Age FROM Individuals I;")
  175. pop$Age <- age$Age
  176. pop$Income[pop$ID %in% povID] <- "Poverty"
  177. pop$Income[!(pop$ID %in% povID)] <- "No Poverty"
  178. #pop$Region <- dbGetQuery(con, "SELECT H.Region_Num FROM Household H, Individuals I WHERE I.Household_ID = H.Household_ID;") FIX THIS REGION ORDERING
  179. pop$health_status <- 0 #everyone healthy
  180. pop$health_status[pop$ID %in% inf_IDs] <- 1 #initial infected in health_status
  181. pop$inf_count <- 0 #0 people initially infected
  182. pop$k_node <- 0 #everyone not k_node
  183. pop$Purdue <- "No"
  184. purdue <- dbGetQuery(con, "SELECT I.Person_ID AS Person_ID FROM Individuals I, Works_At W WHERE I.Person_ID = W.Person_ID AND W.Work_ID = 1000")
  185. pop$Purdue[purdue$Person_ID] <- "Yes"
  186. region <- dbGetQuery(con, "SELECT I.Person_ID AS ID, R.Region_Num AS Region FROM Region R, Individuals I, Household H WHERE I.Household_ID = H.Household_ID AND H.Region_Num = R.Region_Num;")
  187. pop$Region[region$ID] <- region$Region[pop$ID %in% region$ID]
  188. schools <- dbGetQuery(con, "SELECT I.Person_ID AS ID FROM Individuals I, Works_At W WHERE I.Person_ID = W.Person_ID AND W.Work_ID IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);")
  189. pop$School <- "No"
  190. pop$School[schools$ID] <- "Yes"
  191. bus <- dbGetQuery(con, "SELECT I.Person_ID AS ID FROM Individuals I, Household H WHERE I.Household_ID = H.Household_ID AND H.PubTrans = 'YES';")
  192. pop$Bus <- "No"
  193. pop$Bus[bus$ID] <- "Yes"
  194. ################################################ Functions ###########################################
  195. #Disease factor function
  196. f <- function(df, contagious){
  197. within(df, Weight <- Weight * (contagious)) ## CHANGE DISEASE MULTIPLIER HERE
  198. }
  199.  
  200. #randomize order of contacts
  201. randomize <- function(df)
  202. {
  203. df <- df[sample(nrow(df)),]
  204. }
  205.  
  206. #number of contacts shortened to 50
  207. shorten <- function(df)
  208. {
  209. df <- df[c(1:50),]
  210. }
  211.  
  212. #Determines number of contacts per person per day, and split up into work, bus community
  213. contacts <- function(meanContactsDay){
  214. nContacts <- rpois(1,meanContactsDay)
  215. if(nContacts >50 ){nContacts = 50}
  216. else if (nContacts == 0){nContacts = 1}
  217. return(nContacts)
  218. }
  219.  
  220. #Returns queried edges by concatenating strings
  221. getEdges <- function(inf_ID, Query, QueryEnd, numContacts){
  222. SQL <- paste0(Query, inf_ID, QueryEnd, numContacts, ";")
  223. SQL <- gsub("[\n]", " ", SQL)
  224. edges <- dbGetQuery(con, SQL) #concatenates inf_ID with query
  225. return(edges)
  226. }
  227.  
  228. #Gets multiplier for region density for community contacts
  229. getDenMultiplier <- function(inf_ID, QDensity, meanDensity){
  230. SQL <- paste0(QDensity, inf_ID, ";")
  231. SQL <- gsub("[\n]", " ", SQL)
  232. density <- dbGetQuery(con, SQL) #concatenates inf_ID with query
  233. multiplier <- density/meanDensity
  234. return(as.numeric(multiplier))
  235. }
  236.  
  237. raceMult <- function(all_edges, asianID, blackID, hispanicID, amerindianID, multiraceID, raceWeight){
  238. all_edges$Weight[all_edges$Person_ID %in% asianID$AsianID] <- all_edges$Weight[all_edges$Person_ID %in% asianID$AsianID] * raceWeight[1]
  239. all_edges$Weight[all_edges$Person_ID %in% blackID$BlackID] <- all_edges$Weight[all_edges$Person_ID %in% blackID$BlackID] * raceWeight[2]
  240. all_edges$Weight[all_edges$Person_ID %in% hispanicID$HispanicID] <- all_edges$Weight[all_edges$Person_ID %in% hispanicID$HispanicID] * raceWeight[3]
  241. all_edges$Weight[all_edges$Person_ID %in% amerindianID$AmerIndianID] <- all_edges$Weight[all_edges$Person_ID %in% amerindianID$AmerIndianID] * raceWeight[4]
  242. all_edges$Weight[all_edges$Person_ID %in% multiraceID$MultiraceID] <- all_edges$Weight[all_edges$Person_ID %in% multiraceID$MultiraceID] * raceWeight[5]
  243. return(all_edges)
  244. }
  245.  
  246. ageMult <- function(all_edges, infantID, childID, adultID, seniorID, ageWeight){
  247. all_edges$Weight[all_edges$Person_ID %in% infantID$infantID] <- all_edges$Weight[all_edges$Person_ID %in% infantID$infantID] * ageWeight[1]
  248. all_edges$Weight[all_edges$Person_ID %in% childID$childID] <- all_edges$Weight[all_edges$Person_ID %in% childID$childID] * ageWeight[2]
  249. all_edges$Weight[all_edges$Person_ID %in% adultID$adultID] <- all_edges$Weight[all_edges$Person_ID %in% adultID$adultID] * ageWeight[3]
  250. all_edges$Weight[all_edges$Person_ID %in% seniorID$seniorID] <- all_edges$Weight[all_edges$Person_ID %in% seniorID$seniorID] * ageWeight[4]
  251. return(all_edges)
  252. }
  253.  
  254.  
  255. Weight2Prob <- function(all_edges){
  256. all_edges$Weight <- 1 - exp(-all_edges$Weight)
  257. return(all_edges)
  258. }
  259.  
  260. gets_sick <- function(all_edges){
  261. randNo <- runif(length(all_edges$Weight),0,1)
  262. sickID <- all_edges$Person_ID[which(randNo < all_edges$Weight)]
  263. return(sickID)
  264. }
  265.  
  266. dead <- function(inf_IDs, diseaseType, infantID, childID, adultID, seniorID, deathRate){
  267. diseaseWeight <- 1 #base
  268. if (diseaseType == 2){diseaseWeight <- 150 #smallpox
  269. }else if (diseaseType == 3){diseaseWeight <- 3 #measles
  270. }else if (diseaseType == 4){diseaseWeight <- 500} #Ebola
  271. inf <- data.frame(Person_ID = inf_IDs, Weight = diseaseWeight)
  272. temp <- ageMult(inf, infantID, childID, adultID, seniorID, deathRate)
  273. inf$Weight <- temp$Weight #put updated weight onto inf_people
  274. randNo <- runif(length(inf_IDs),0,1)
  275. dead_ID <- inf$Person_ID[which(randNo < inf$Weight)]
  276. return(dead_ID)
  277. }
  278.  
  279. recovered <- function(inf_IDs, diseaseType, RecoveryRate, dead_ID){
  280. if (diseaseType == 2){RecoveryRate <- RecoveryRate*(6/20)} #smallpox #See project report citations
  281. else if (diseaseType == 3){RecoveryRate <- RecoveryRate*(6/8)} #Measels
  282. else if (diseaseType == 4){RecoveryRate <- RecoveryRate*(6/5)} #Ebola ? data
  283. inf <- data.frame(Person_ID = inf_IDs, Weight = RecoveryRate)
  284. randNo <- runif(length(inf_IDs),0,1)
  285. recov_ID <- inf$Person_ID[which(randNo < inf$Weight)]
  286. recov_ID <- recov_ID[!(recov_ID %in% dead_ID)]
  287. return(recov_ID)
  288. }
  289. #
  290. ###########################################Disease spread model#########################################
  291. #Loaded edge list of POSSIBLE contacts per person precalculated in EdgelistRetrieve.R
  292.  
  293.  
  294. listDf2 <- pblapply(listDf, f, contagious) #factor in disease type multiplier
  295. listDf2 <- pblapply(listDf2, Weight2Prob) #Converts weight to probability with 1-exp(-time)
  296. samp <- list()
  297. #List of sample indicies for each number of contacts
  298. for (num in c(1:50)){
  299. samp[[num]] <- sample(50, num)
  300. }
  301.  
  302. for (day in 2:duration){ #time step loop, starting on day 2
  303. cat("Current Day:", day, "\n")
  304. for (inf_ID in inf_IDs){ #loop through all infected individuals on day "day"
  305.  
  306. #Acquire contacted individuals + weight values
  307. numContacts <- contacts(meanContactsDay) #function to determine poisson random variable total contacts
  308. contactsDay <- listDf2[[inf_ID]][samp[[numContacts]],] #use corresponding random sample from the 50 contacts of this person
  309. #compiles all edges for entire simulation (for network viz)
  310. #tempID <- data.frame(ID1 = rep(inf_ID, nrow(contactsDay)), ID2 = contactsDay$Person_ID)
  311. #totalEdges <- merge(totalEdges, tempID, all = T) TAKES TOO LONG
  312.  
  313. #Factor in race and disease
  314. sickID <- gets_sick(contactsDay) #returns IDs of all people who newly get sick :
  315.  
  316. #gets_sick function (in: data frame of contacted individID and weights, infection rate | out: individID of infected)
  317. pop$inf_count[inf_ID] <- pop$inf_count[inf_ID] + length(sickID) #Updates # people this individual infected
  318. nextInf_IDs <- c(nextInf_IDs, sickID) #compiles those who will be sick tomorrow
  319. }
  320. #######End of Day i! Who recovered? Who died? ###############
  321. nextInf_IDs <- unique(nextInf_IDs) #gets rid of repeated contacts during that day
  322. nextInf_IDs <- union(nextInf_IDs, inf_IDs) #include those who were infected at start of day with nextInf_IDs
  323. if (length(inf_IDs) != 0){ #only see who is dead/recovered if ppl are infected
  324. dead_ID <- dead(inf_IDs, diseaseType, infantID, childID, adultID, seniorID, deathRate)
  325. cumDead_ID <- union(cumDead_ID, dead_ID)
  326. recov_ID <- recovered(inf_IDs, diseaseType, RecoveryRate, cumDead_ID)
  327. cumRecov_ID <- union(cumRecov_ID, recov_ID) #gets cumulative unique IDs of recovered people (for igraph)
  328. }
  329. inf_IDs <- nextInf_IDs[!(nextInf_IDs %in% c(cumRecov_ID, cumDead_ID))] #remove those who recovered or died from infected list, forms group of infected for next day
  330. #Update health status of pop data frame
  331. pop$health_status[pop$ID %in% inf_IDs] <- 1
  332. pop$health_status[pop$ID %in% recov_ID] <- 2
  333. pop$health_status[pop$ID %in% dead_ID] <- 3
  334. #Get the number of individuals infected, recovered, dead, susceptible for this day into vector index
  335. numInfected[day] <- length(inf_IDs)
  336. numRecovered[day] <- length(cumRecov_ID)
  337. numDead[day] <- length(cumDead_ID)
  338. susceptible[day] <- totalPeople - numInfected[day] - numRecovered[day] - numDead[day]
  339. #New live-updating infected group for next day
  340. nextInf_IDs <- inf_IDs
  341. cat(numInfected[day], "Infected as of Day", day, "\n")
  342. }
  343.  
  344. #If no one infected on last day of simulation, extend data until end of 100 days.
  345. if(numInfected[length(numInfected)] == 0){numInfected[length(numInfected):100] <- 0
  346. numRecovered[length(numRecovered):100] <- numRecovered[length(numRecovered)]
  347. numDead[length(numDead):100] <- numDead[length(numDead)]
  348. susceptible[length(susceptible):100] <- susceptible[length(susceptible)]}
  349.  
  350. plot(0,0,xlim = c(0,duration + 1),ylim = c(0,totalPeople), type = "n", xlab = "Day", ylab = "Number of People", main = "SIR Model of West Lafayette and Lafayette Population over Time")
  351. legend(80,120000, c("Infected", "Recovered", "Dead", "Susceptible"), col = c("red", "green", "black", "blue"), lwd = 1)
  352. lines(1:duration, numInfected, col = "red")
  353. lines(1:duration, numRecovered, col = "green")
  354. lines(1:duration, numDead, col = "black")
  355. lines(1:duration, susceptible, col = "blue")
  356. #nextInf_Ids: real-time updating ID vector of currently sick
  357. #inf_Ids: ID vector of sick at start of day (have chance of recover/die at end of day)
  358. #sickID: ID vector of those who get sick from one inf_ID iteration
  359. #inf_Id : infected individual lcv
  360.  
  361. #K-Node determination
  362. k_number <- floor(kPct * max(numInfected))
  363. k_nodes <- head(pop[order(-pop$inf_count),],n = k_number) #Sort in descending order by scored individuals (inf_count)
  364. #Number of rows to use based on user input of k-node pct
  365. pop$k_node[pop$ID %in% k_nodes$ID] <- 1 #Assign K-node status in pop
  366.  
  367. infDays <- sum(numInfected) #Use in cost calculation for policy
  368. #pop is now our dataset for machine learning with pop$k_node as the prediction variable
  369. #
  370. # #Percentage of SIRD from total population vectors for SIRD plot (input to animate function)
  371. # pctSusc <- (susceptible/totalPeople) * 100
  372. # pctInf <- (infected/totalPeople)*100
  373. # pctRecov <- (recovered/totalPeople)*100
  374. # pctDead <- (dead/totalPeople)*100
  375. #
  376. # #igraph visualization ONLY IF WE HAVE TIME
  377. # netEdges$Weight <- NULL #unweighted network (probably too large of network to use weights)
  378. # simplify(netEdges) #remove redundant edges
  379. # g <- graph_from_edgelist(netEdges, directed=F, vertices=nodes)
  380. # #color of nodes
  381. # V(g)$color <- ifelse(V(g)$ID1 %in% inf_Ids | V(g)$ID2 %in% inf_Ids, "red",
  382. # ifelse(V(g)$ID1 %in% cumRecov_ID | V(g)$ID2 %in% cumRecov_ID, "green", "black"))
  383. #
  384. #Disconnect from DB
  385.  
  386. save(pop,numInfected, numRecovered, numDead, susceptible, infDays, file = sprintf("Case%d.rda", iter))
  387. all_cons <- dbListConnections(MySQL())
  388. for (con in all_cons)
  389. dbDisconnect(con)
  390. rm(list=setdiff(ls(), c("iter", "d", "n", "k"))) #clears workspace
  391. iter <- iter + 1
  392. }
  393. }
  394. }
Add Comment
Please, Sign In to add comment