library(data.table) #fread
library(sp) #used by rgdal
library(rgdal) #readOGR
library(ggplot2) #fortify
library(plyr) #join
library(dplyr) #left_join
library(scales) #percent
library(viridisLite)
library(viridis)
library(openintro) #state2abbr
library(rgeos) #gCentroid
library(cdlTools) #fips
library(ggmap) #theme_nothing
ARIS (American Religious Identification Survey)
The Association of Religion Data Archives (ARDA)
American Religious Identification Survey, 2008
The American Religious Identification Survey (ARIS) 2008 is the third in a landmark time series of large, nationally representative surveys that track changes in the religious loyalties of the U.S. adult population within the 28 contiguous states from 1990 to 2008. The 2001 and 2008 surveys are replicas of the 1990 survey, and are led by the same academic research team using an identical methodology of random-digit-dialed telephone interviews (RDD) and the same unprompted, open-ended key question “What is your religion, if any?” Interviewers did not prompt or offer a suggested list of potential answers. Moreover, the self-description of respondents was not based on whether established religious bodies or institutions considered them to be members. To the contrary, the surveys sought to determine whether the respondents regarded themselves as adherents of a religious community. The surveys tap subjective, rather than objective, standards of religious identification. The value of this unique series of national surveys, which allows scientific monitoring of change over time, has been recognized by the U.S. Bureau of the Census The Bureau itself is constitutionally precluded from such an inquiry into religion, and so has incorporated NSRI/ARIS findings into its official publication the Statistical Abstract of the United States since 2003.
Cases: 54,461
Variables: 33
Weight Variable: POPWGHT
Date Collected: February - November 2008
cf. Religious Population by State
ARIS2008 <- fread("ARIS2008.csv")
str(ARIS2008)
Classes ‘data.table’ and 'data.frame': 54461 obs. of 38 variables:
$ CASEID : int 102 166 184 199 228 255 283 285 297 316 ...
$ WEEK : int 203 203 203 203 203 203 203 203 203 203 ...
$ POPWGHT : num 0.412 1.884 0.915 0.927 0.062 ...
$ STATE : chr "GA" "TX" "AZ" "CA" ...
$ DMA : int 524 709 753 807 524 501 537 521 810 807 ...
$ NEILSEN : chr "D" "D" "B" "A" ...
$ COUNTYC : int 137 401 15 81 59 25 19 5 77 85 ...
$ ADI : int 197 323 275 65 197 9 357 47 339 65 ...
$ METRO : chr "Non-Metro" "Non-Metro" "Suburban (Metro)" "Suburban (Metro)" ...
$ REGION : chr "South" "South" "West" "West" ...
$ DIVISION : chr "South Atlantic" "West South Central" "Mountain" "Pacific" ...
$ OWNHOME : chr "Rented" "Rented" "Rented" "Owned" ...
$ MARITAL : chr "Single, living with a partner" "Single, living with a partner" "Married" "Married" ...
$ HEADHH : chr "Don't know" "No" "No" "Yes" ...
$ EMPLOY : chr "Temporarily unemployed" "Other not employed" "Housewife" "Full-time" ...
$ HHCOMP : chr "Six" "Refused" "Five" "Four" ...
$ ADULTS : chr "Two" "" "Two" "Two" ...
$ ADULTM : chr "One" "" "One" "One" ...
$ ADULTF : chr "One" "" "One" "One" ...
$ KIDS1217 : chr "Three" "" "None" "Two" ...
$ KIDS611 : chr "None" "" "Three" "None" ...
$ KIDS06 : chr "One" "" "None" "None" ...
$ AGE : chr "35" "19" "27" "40" ...
$ EDUC : chr "Less than high school graduate" "Refused" "High school graduate" "High school graduate" ...
$ INCOME : chr "Don't know" "Refused" "Less than $10,000" "$75,000 but less than $100,000" ...
$ RACE : chr "Black Hispanic" "White Hispanic" "White Hispanic" "Unspecified" ...
$ POLAFFIL : chr "Refused" "Refused" "An Independent" "A Democrat" ...
$ REGVOTE : chr "No" "Refused" "No" "Yes" ...
$ OTHTEL : chr "None" "Refused" "None" "None" ...
$ SEX : chr "Male" "Female" "Female" "Female" ...
$ RELIG : chr "Don't know" "Catholic, Roman Catholic" "Apostolic/New Apostolic" "Catholic, Roman Catholic" ...
$ RELIG2 : chr "" "" "" "" ...
$ RELIG3 : chr "" "" "" "" ...
$ I_SEX : chr "Male" "Female" "Female" "Female" ...
$ I_MARITAL : chr "Single" "Single" "Married" "Married" ...
$ I_EDUC : chr "Less than high school graduate" "" "High school graduate" "High school graduate" ...
$ I_PARTYID : chr "" "" "An Independent or other affiliation" "A Democrat" ...
$ I_RELIGION: chr "" "Catholic" "Other religion" "Catholic" ...
- attr(*, ".internal.selfref")=<externalptr>
major <- names(head(sort(prop.table(table(ARIS2008$RELIG)), decreasing=TRUE), 17))
major
[1] "Catholic, Roman Catholic"
[2] "Christian"
[3] "No religion/none"
[4] "Baptist"
[5] "Protestant"
[6] "Refused"
[7] "Lutheran"
[8] "Methodist/Wesleyan"
[9] "Presbyterian"
[10] "Jewish, Judaism"
[11] "Mormon/Church of Jesus Christ of Latter-day Saints"
[12] "Pentecostal"
[13] "Non-denominational Christian"
[14] "United Methodist"
[15] "Episcopalian/Anglican"
[16] "Don't know"
[17] "Southern Baptist"
ARIS2008_major <- ARIS2008[RELIG %in% major,]
nrow(ARIS2008_major)
[1] 50287
ggplot(ARIS2008_major, aes(RELIG)) +
geom_bar(mapping = aes(x = RELIG, y = ..prop.., group = 1), stat = "count") +
scale_y_continuous(labels = scales::percent) +
coord_flip()+theme(axis.text = element_text(size = 7))
prop.table(table(ARIS2008_major$RELIG, ARIS2008_major$POLAFFIL), margin=1)
A Democrat A Republican An Independent
Baptist 0.409696970 0.284155844 0.230129870
Catholic, Roman Catholic 0.349144171 0.262624542 0.302733543
Christian 0.254428537 0.369570493 0.302353798
Don't know 0.300601202 0.140280561 0.364729459
Episcopalian/Anglican 0.336092715 0.324503311 0.286423841
Jewish, Judaism 0.527412281 0.143640351 0.279605263
Lutheran 0.300906056 0.346208870 0.271816881
Methodist/Wesleyan 0.345850999 0.336765597 0.252574197
Mormon/Church of Jesus Christ of Latter-day Saints 0.117496807 0.549169860 0.263090677
No religion/none 0.345891966 0.142532910 0.410198215
Non-denominational Christian 0.273087071 0.306068602 0.329815303
Pentecostal 0.373056995 0.278497409 0.237046632
Presbyterian 0.287575150 0.405811623 0.256513026
Protestant 0.266201009 0.383391541 0.289483896
Refused 0.214257109 0.136964357 0.299959952
Southern Baptist 0.295711061 0.415349887 0.250564334
United Methodist 0.333333333 0.344000000 0.264000000
Don't know Other Refused
Baptist 0.036190476 0.009696970 0.030129870
Catholic, Roman Catholic 0.034403474 0.013625138 0.037469131
Christian 0.029119146 0.016622179 0.027905848
Don't know 0.112224449 0.016032064 0.066132265
Episcopalian/Anglican 0.013245033 0.014900662 0.024834437
Jewish, Judaism 0.010964912 0.014254386 0.024122807
Lutheran 0.033381021 0.012398665 0.035288507
Methodist/Wesleyan 0.031496063 0.004239855 0.029073289
Mormon/Church of Jesus Christ of Latter-day Saints 0.029374202 0.014048531 0.026819923
No religion/none 0.044484793 0.018610985 0.038281132
Non-denominational Christian 0.032981530 0.022427441 0.035620053
Pentecostal 0.050518135 0.014248705 0.046632124
Presbyterian 0.016032064 0.013026052 0.021042084
Protestant 0.022700815 0.009507179 0.028715561
Refused 0.022426912 0.019223068 0.307168602
Southern Baptist 0.015801354 0.011286682 0.011286682
United Methodist 0.024000000 0.008000000 0.026666667
prop.table(table(ARIS2008_major$RELIG, ARIS2008_major$REGVOTE), margin=1)
Don't know No Refused Yes
Baptist 0.004675325 0.128658009 0.007099567 0.859567100
Catholic, Roman Catholic 0.003235970 0.133866985 0.014221238 0.848675807
Christian 0.005095851 0.140499879 0.007037127 0.847367144
Don't know 0.018036072 0.214428858 0.018036072 0.749498998
Episcopalian/Anglican 0.003311258 0.086092715 0.003311258 0.907284768
Jewish, Judaism 0.008771930 0.081140351 0.006578947 0.903508772
Lutheran 0.004768717 0.090605627 0.007153076 0.897472580
Methodist/Wesleyan 0.003634161 0.083585706 0.008479709 0.904300424
Mormon/Church of Jesus Christ of Latter-day Saints 0.002554278 0.108556833 0.003831418 0.885057471
No religion/none 0.005144500 0.188076865 0.008473294 0.798305341
Non-denominational Christian 0.003957784 0.160949868 0.003957784 0.831134565
Pentecostal 0.010362694 0.176165803 0.007772021 0.805699482
Presbyterian 0.000000000 0.067134269 0.007014028 0.925851703
Protestant 0.002716337 0.077609624 0.005820722 0.913853318
Refused 0.004405286 0.082098518 0.148177813 0.765318382
Southern Baptist 0.004514673 0.110609481 0.004514673 0.880361174
United Methodist 0.002666667 0.078666667 0.002666667 0.916000000
sort(unique(ARIS2008$STATE))
[1] "AL" "AR" "AZ" "CA" "CO" "CT" "DC" "DE" "FL" "GA" "IA" "ID" "IL" "IN" "KS" "KY" "LA" "MA" "MD"
[20] "ME" "MI" "MN" "MO" "MS" "MT" "NC" "ND" "NE" "NH" "NJ" "NM" "NV" "NY" "OH" "OK" "OR" "PA" "RI"
[39] "SC" "SD" "TN" "TX" "UT" "VA" "VT" "WA" "WI" "WV" "WY"
lower_48 <- c("01", "04", "05", "06", "08", "09", "10", "11", "12", "13", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "44", "45", "46", "47", "48", "49", "50", "51", "53", "54", "55", "56")
United States Census Bureau, Cartographic Boundary Files - Shapefile
cb_2018_us_state_500k.zip
states.sh <- readOGR("C:/Users/14165/Desktop/Shapefiles/cb_2018_us_state_500k", "cb_2018_us_state_500k", stringsAsFactors=FALSE)
OGR data source with driver: ESRI Shapefile
Source: "C:\Users\14165\Desktop\Shapefiles\cb_2018_us_state_500k", layer: "cb_2018_us_state_500k"
with 56 features
It has 9 fields
Integer64 fields read as strings: ALAND AWATER
str(states.sh@data)
'data.frame': 56 obs. of 9 variables:
$ STATEFP : chr "28" "37" "40" "51" ...
$ STATENS : chr "01779790" "01027616" "01102857" "01779803" ...
$ AFFGEOID: chr "0400000US28" "0400000US37" "0400000US40" "0400000US51" ...
$ GEOID : chr "28" "37" "40" "51" ...
$ STUSPS : chr "MS" "NC" "OK" "VA" ...
$ NAME : chr "Mississippi" "North Carolina" "Oklahoma" "Virginia" ...
$ LSAD : chr "00" "00" "00" "00" ...
$ ALAND : chr "121533519481" "125923656064" "177662925723" "102257717110" ...
$ AWATER : chr "3926919758" "13466071395" "3374587997" "8528531774" ...
states_lower48.sh <- states.sh[states.sh@data$GEOID %in% lower_48,]
str(states_lower48.sh@data)
'data.frame': 49 obs. of 9 variables:
$ STATEFP : chr "28" "37" "40" "51" ...
$ STATENS : chr "01779790" "01027616" "01102857" "01779803" ...
$ AFFGEOID: chr "0400000US28" "0400000US37" "0400000US40" "0400000US51" ...
$ GEOID : chr "28" "37" "40" "51" ...
$ STUSPS : chr "MS" "NC" "OK" "VA" ...
$ NAME : chr "Mississippi" "North Carolina" "Oklahoma" "Virginia" ...
$ LSAD : chr "00" "00" "00" "00" ...
$ ALAND : chr "121533519481" "125923656064" "177662925723" "102257717110" ...
$ AWATER : chr "3926919758" "13466071395" "3374587997" "8528531774" ...
Add “id” column
states_lower48.sh@data$id <- as.integer(states_lower48.sh@data$GEOID)
sort(states_lower48.sh@data$id)
[1] 1 4 5 6 8 9 10 11 12 13 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
[33] 38 39 40 41 42 44 45 46 47 48 49 50 51 53 54 55 56
states_lower48.sh@data$STATE <- as.character(states_lower48.sh@data$STUSPS)
Shapefile processing
states_lower48.points = fortify(states_lower48.sh, region = "id")
states_lower48.df = join(states_lower48.points, states_lower48.sh@data, by = "id")
Totals2008 <- ARIS2008[, .(.N), by = .(STATE)]
Totals2008 <- Totals2008[order(STATE)]
Catholics2008 <- ARIS2008[RELIG == "Catholic, Roman Catholic", .(.N), by = .(STATE)]
Catholics2008 <- Catholics2008[order(STATE)]
Catholics2008$ratio <- Catholics2008$N/Totals2008$N
Catholics2008_lower48 <- merge(states_lower48.df, Catholics2008, by = "STATE")
Catholics2008_lower48 <- Catholics2008_lower48[order(Catholics2008_lower48$STATE), ]
Make and plot choropleth
ggplot() +
geom_polygon(data = Catholics2008_lower48,
aes(x = long, y = lat, group = group, fill = ratio),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Catholics") +
labs(title="Ratios of Catholics by State, ARIS2008")
Baptists2008 <- ARIS2008[RELIG == "Baptist", .(.N), by = .(STATE)]
Baptists2008 <- Baptists2008[order(STATE)]
Baptists2008$ratio <- Baptists2008$N/Totals2008$N
Baptists2008_lower48 <- merge(states_lower48.df, Baptists2008, by = "STATE")
Baptists2008_lower48 <- Baptists2008_lower48[order(Baptists2008_lower48$STATE), ]
Make and plot choropleth
ggplot() +
geom_polygon(data = Baptists2008_lower48,
aes(x = long, y = lat, group = group, fill = ratio),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Baptists") +
labs(title="Ratios of Baptists by State, ARIS 2008")
Noreligion2008 <- ARIS2008[RELIG == "No religion/none", .(.N), by = .(STATE)]
Noreligion2008 <- Noreligion2008[order(STATE)]
Noreligion2008$ratio <- Noreligion2008$N/Totals2008$N
Noreligion2008_lower48 <- merge(states_lower48.df, Noreligion2008, by = "STATE")
Noreligion2008_lower48 <- Noreligion2008_lower48[order(Noreligion2008_lower48$STATE), ]
Make and plot choropleth
ggplot() +
geom_polygon(data = Noreligion2008_lower48,
aes(x = long, y = lat, group = group, fill = ratio),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="No Religion") +
labs(title="Ratios of No Religion by State, ARIS 2008")
ARIS2001SPSS.zip
ARIS2001 <- fread("ARIS2001.csv")
ARIS2001 <- ARIS2001[, .(POPWGHT = wgt_pop, STATE = state, COUNTYFIPS = fips, ADI = adi, DMA = dma, MSA = msa, METRO = metro, NIELSEN = neilsen, DIVISION = cen_div, REGION = region, SEX = gender, OWNHOME = dem2, MARITAL = dem3, EMPLOY = dem4, INCOME = newdem9, AGE = dem7, EDUC = dem8, HISPANIC = dem10, RACE = dem11, RELIG = jq1tot, RELIG_SPOUSE = jq2tot, AGECAT = agecat, POLAFFIL = z11a, REGVOTE = z11b)]
ARIS2001$STATE <- state2abbr(ARIS2001$STATE)
major_2001 <- names(head(sort(prop.table(table(ARIS2001$RELIG)), decreasing=TRUE), 17))
major_2001
[1] "Catholic" "Baptist"
[3] "None" "Methodist/Wesleyan"
[5] "Christian" "Refused"
[7] "Lutheran" "Presbyterian"
[9] "Protestant" "Pentecostal/Charismatics"
[11] "Southern Baptist" "Episcopalian"
[13] "Mormon/Latter Day Saints" "Churches of Christ & Christian Churches"
[15] "Non-denominational" "Jewish/Judaism"
[17] "United Church of Christ/Congregational"
ARIS2001_major <- ARIS2001[RELIG %in% major_2001,]
nrow(ARIS2001_major)
[1] 46021
ggplot(ARIS2001_major, aes(RELIG)) +
geom_bar(mapping = aes(x = RELIG, y = ..prop.., group = 1), stat = "count") +
scale_y_continuous(labels = scales::percent) +
coord_flip()+theme(axis.text = element_text(size = 7))
Totals2001 <- ARIS2001[, .(.N), by = .(STATE)]
Totals2001 <- Totals2001[order(STATE)]
Catholics2001 <- ARIS2001[RELIG == "Catholic", .(.N), by = .(STATE)]
Catholics2001 <- Catholics2001[order(STATE)]
Catholics2001$ratio <- Catholics2001$N/Totals2001$N
Catholics2001_lower48 <- merge(states_lower48.df, Catholics2001, by = "STATE")
Catholics2001_lower48 <- Catholics2001_lower48[order(Catholics2001_lower48$STATE), ]
Make and plot choropleth
ggplot() +
geom_polygon(data = Catholics2001_lower48,
aes(x = long, y = lat, group = group, fill = ratio),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Catholics") +
labs(title="Ratios of Catholics by State, ARIS 2001")
Baptists2001 <- ARIS2001[RELIG == "Baptist", .(.N), by = .(STATE)]
Baptists2001 <- Baptists2001[order(STATE)]
Baptists2001$ratio <- Baptists2001$N/Totals2001$N
Baptists2001_lower48 <- merge(states_lower48.df, Baptists2001, by = "STATE")
Baptists2001_lower48 <- Baptists2001_lower48[order(Baptists2001_lower48$STATE), ]
ggplot() +
geom_polygon(data = Baptists2001_lower48,
aes(x = long, y = lat, group = group, fill = ratio),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Baptists") +
labs(title="Ratios of Baptists by State, ARIS 2001")
Noreligion2001 <- ARIS2001[RELIG == "None", .(.N), by = .(STATE)]
Noreligion2001 <- Noreligion2001[order(STATE)]
Noreligion2001$ratio <- Noreligion2001$N/Totals2001$N
Noreligion2001_lower48 <- merge(states_lower48.df, Noreligion2001, by = "STATE")
Noreligion2001_lower48 <- Noreligion2001_lower48[order(Noreligion2001_lower48$STATE), ]
ggplot() +
geom_polygon(data = Noreligion2001_lower48,
aes(x = long, y = lat, group = group, fill = ratio),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="No Religion") +
labs(title="Ratios of No Religion by State, ARIS 2001")
Catholics2008$change <- (Catholics2008$ratio-Catholics2001$ratio)/Catholics2001$ratio
Catholics2008change_lower48 <- merge(states_lower48.df, Catholics2008, by = "STATE")
Catholics2008change_lower48 <- Catholics2008change_lower48[order(Catholics2008change_lower48$STATE), ]
Make and plot choropleth
ggplot() +
geom_polygon(data = Catholics2008change_lower48,
aes(x = long, y = lat, group = group, fill = change),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Change") +
labs(title="(ARIS2008-ARIS2001)/ARIS2001, Catholics")
Baptists2008$change <- (Baptists2008$ratio-Baptists2001$ratio)/Baptists2001$ratio
Baptists2008change_lower48 <- merge(states_lower48.df, Baptists2008, by = "STATE")
Baptists2008change_lower48 <- Baptists2008change_lower48[order(Baptists2008change_lower48$STATE), ]
ggplot() +
geom_polygon(data = Baptists2008change_lower48,
aes(x = long, y = lat, group = group, fill = change),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Change") +
labs(title="(ARIS2008-ARIS2001)/ARIS2001, Baptists")
Noreligion2008$change <- (Noreligion2008$ratio-Noreligion2001$ratio)/Noreligion2001$ratio
Noreligion2008change_lower48 <- merge(states_lower48.df, Noreligion2008, by = "STATE")
Noreligion2008change_lower48 <- Noreligion2008change_lower48[order(Noreligion2008change_lower48$STATE), ]
ggplot() +
geom_polygon(data = Noreligion2008change_lower48,
aes(x = long, y = lat, group = group, fill = change),
color = "white", size = 0.1) +
coord_map() +
scale_fill_viridis(option="magma", labels=percent, name="Change") +
labs(title="(ARIS2008-ARIS2001)/ARIS2001, No Religion")
ARIS2008_counties <- ARIS2008[,.(COUNTYFIPS = COUNTYC, STATE, RELIG)]
ARIS2008_counties$STATEFIPS <- fips(ARIS2008_counties$STATE, to = "FIPS")
United States Census Bureau, Cartographic Boundary Files - Shapefile
cb_2018_us_county_500k.zip
counties.sh <- readOGR("C:/Users/14165/Desktop/Shapefiles/cb_2018_us_county_500k", "cb_2018_us_county_500k", stringsAsFactors=FALSE)
OGR data source with driver: ESRI Shapefile
Source: "C:\Users\14165\Desktop\Shapefiles\cb_2018_us_county_500k", layer: "cb_2018_us_county_500k"
with 3233 features
It has 9 fields
Integer64 fields read as strings: ALAND AWATER
str(counties.sh@data)
'data.frame': 3233 obs. of 9 variables:
$ STATEFP : chr "21" "21" "21" "21" ...
$ COUNTYFP: chr "007" "017" "031" "065" ...
$ COUNTYNS: chr "00516850" "00516855" "00516862" "00516879" ...
$ AFFGEOID: chr "0500000US21007" "0500000US21017" "0500000US21031" "0500000US21065" ...
$ GEOID : chr "21007" "21017" "21031" "21065" ...
$ NAME : chr "Ballard" "Bourbon" "Butler" "Estill" ...
$ LSAD : chr "06" "06" "06" "06" ...
$ ALAND : chr "639387454" "750439351" "1103571974" "655509930" ...
$ AWATER : chr "69473325" "4829777" "13943044" "6516335" ...
counties_lower48.sh <- counties.sh[counties.sh@data$STATEFP %in% lower_48,]
counties_lower48.sh@data$STATEFIPS <- as.integer(counties_lower48.sh@data$STATEFP)
counties_lower48.sh@data$COUNTYFIPS <- as.integer(counties_lower48.sh@data$COUNTYFP)
counties_lower48.centroids <- as.data.table(gCentroid(counties_lower48.sh, byid = TRUE))
counties_lower48.centroids$STATEFIPS <- counties_lower48.sh@data$STATEFIPS
counties_lower48.centroids$COUNTYFIPS <- counties_lower48.sh@data$COUNTYFIPS
str(counties_lower48.centroids)
Classes ‘data.table’ and 'data.frame': 3108 obs. of 4 variables:
$ x : num -89 -84.2 -86.7 -84 -83.7 ...
$ y : num 37.1 38.2 37.2 37.7 38.4 ...
$ STATEFIPS : int 21 21 21 21 21 21 21 21 21 21 ...
$ COUNTYFIPS: int 7 17 31 65 69 93 99 131 151 155 ...
- attr(*, ".internal.selfref")=<externalptr>
str(ARIS2008_counties)
Classes ‘data.table’ and 'data.frame': 54461 obs. of 4 variables:
$ COUNTYFIPS: int 137 401 15 81 59 25 19 5 77 85 ...
$ STATE : chr "GA" "TX" "AZ" "CA" ...
$ RELIG : chr "Don't know" "Catholic, Roman Catholic" "Apostolic/New Apostolic" "Catholic, Roman Catholic" ...
$ STATEFIPS : int 13 48 4 6 13 34 23 25 53 6 ...
- attr(*, ".internal.selfref")=<externalptr>
ARIS2008_XY <- left_join(ARIS2008_counties, counties_lower48.centroids, by = c("STATEFIPS", "COUNTYFIPS"))
ARIS2008_XY$COUNTYFIPS <- NULL
ARIS2008_XY$STATE <- NULL
ARIS2008_XY$STATEFIPS <- NULL
str(ARIS2008_XY)
'data.frame': 54461 obs. of 3 variables:
$ RELIG: chr "Don't know" "Catholic, Roman Catholic" "Apostolic/New Apostolic" "Catholic, Roman Catholic" ...
$ x : num -83.5 -94.8 -113.8 -122.3 -83.4 ...
$ y : num 34.6 32.1 35.7 37.4 34 ...
Catholics2008_XY <- ARIS2008_XY[ARIS2008_XY$RELIG == "Catholic, Roman Catholic",]
Catholics2008_XY$RELIG <- NULL
Baptists2008_XY <- ARIS2008_XY[ARIS2008_XY$RELIG == "Baptist",]
Baptists2008_XY$RELIG <- NULL
Noreligion2008_XY <- ARIS2008_XY[ARIS2008_XY$RELIG == "No religion/none",]
Noreligion2008_XY$RELIG <- NULL
ggplot() +
geom_polygon(data = states_lower48.df, aes(x = long, y = lat, group = group),
color = 'black', size = 1, fill=NA) +
stat_density2d(data=Catholics2008_XY, aes(x=x, y=y, fill=..level..), alpha=0.2, geom = 'polygon', colour = 'black', contour=TRUE) +
scale_fill_continuous(low="yellow", high="red")+
theme_nothing(legend = TRUE) +
labs(title="Catholic Denity Map, ARIS 2008")
ggplot() +
geom_polygon(data = states_lower48.df, aes(x = long, y = lat, group = group),
color = 'black', size = 1, fill=NA) +
stat_density2d(data=Baptists2008_XY, aes(x=x, y=y, fill=..level..), alpha=0.2, geom = 'polygon', colour = 'black', contour=TRUE) +
scale_fill_continuous(low="yellow",high="red")+
theme_nothing(legend = TRUE) +
labs(title="Baptist Density Map, ARIS 2008")
ggplot() +
geom_polygon(data = states_lower48.df, aes(x = long, y = lat, group = group),
color = 'black', size = 1, fill=NA) +
stat_density2d(data=Noreligion2008_XY, aes(x=x, y=y, fill=..level..), alpha=0.2, geom = 'polygon', colour = 'black', contour=TRUE) +
scale_fill_continuous(low="yellow",high="red")+
theme_nothing(legend = TRUE) +
labs(title="No Religion Density Map, ARIS 2008")