-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting_setUpParallel.R
38 lines (32 loc) · 1.19 KB
/
testing_setUpParallel.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library(parallel)
library(h2o)
library(foreign)
library(maptools)
library(maps)
library(spdep)
library(sp)
library(rgdal)
library(plyr)
numCores <- detectCores()
clust <- makeCluster(numCores)
h2o.init(nthreads = 4)
a<-Sys.time()
cbgs <- readOGR(dsn = "/Users/manchongleong/Desktop/Crate/Projects/NIH/Env_Mixtures/Racial_isolation_index_calculation/Data",
layer = "NC_surrounding_bg_carto_2010")
# Import dbf files.
dbfBgs <- read.dbf("/Users/manchongleong/Desktop/Crate/Projects/NIH/Env_Mixtures/Racial_isolation_index_calculation/Data/cen2010_NC_surrounding_BG_RI.dbf")
# Create a variable with the same name as cbgs.
dbfBgs$GEOID10 <- dbfBgs$stfid10_bg
# Merge two dataframe.
mergeCbgs <- merge(cbgs, dbfBgs, by = "GEOID10")
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # Step 1.2 Create adjacency matrix # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # #
summary(mergeCbgs)
dim(mergeCbgs)
# Follow the example code to create a variable named FullFips.
mergeCbgs$FullFips <- mergeCbgs$GEOID10
# plot(mergeCbgs, lwd=.1, main='Plot of Census Bgs')
# Constructs neighbors from a polygon list.
neighbor <- poly2nb(mergeCbgs)
b<-Sys.time()