q25 = Do you think there has been too much, too little or the right amount of expression of religious faith and prayer by political leaders?
q26 = At the present time, do you think religion as a whole is increasing its influence on American life or losing its influence?
q27 = All in all, do you think this is a good thing or a bad thing?
q28 = How important is it to you that a president shares your religious beliefs? Is it [READ IN ORDER]?
library(foreign)#librerías necesarias
library(dplyr)#librerías necesarias
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)#librerías necesarias
library(plotrix) #librerías necesarias
dt <- read.spss('Jan16 public.sav', to.data.frame=TRUE) #carga el dataset
## Warning in read.spss("Jan16 public.sav", to.data.frame = TRUE): Jan16
## public.sav: Unrecognized record type 7, subtype 14 encountered in system
## file
## Warning in read.spss("Jan16 public.sav", to.data.frame = TRUE): Jan16
## public.sav: Unrecognized record type 7, subtype 18 encountered in system
## file
## Warning in read.spss("Jan16 public.sav", to.data.frame = TRUE): Jan16
## public.sav: Unrecognized record type 7, subtype 24 encountered in system
## file
reinfluence <- dt %>% group_by(q26,party) %>%
filter(q26 == "Increasing influence") %>%
summarise(frec = n())
reinfluence
## Source: local data frame [6 x 3]
## Groups: q26 [?]
##
## q26 party frec
## <fctr> <fctr> <int>
## 1 Increasing influence Republican 97
## 2 Increasing influence Democrat 182
## 3 Increasing influence Independent 198
## 4 Increasing influence (VOL) No preference 20
## 5 Increasing influence (VOL) Other party 5
## 6 Increasing influence (VOL) Don't know/Refused 8
rething <- dt %>% group_by(q27,party) %>%
filter(q27 == "Bad thing") %>%
summarise(frec = n())
rething
## Source: local data frame [6 x 3]
## Groups: q27 [?]
##
## q27 party frec
## <fctr> <fctr> <int>
## 1 Bad thing Republican 412
## 2 Bad thing Democrat 321
## 3 Bad thing Independent 449
## 4 Bad thing (VOL) No preference 58
## 5 Bad thing (VOL) Other party 11
## 6 Bad thing (VOL) Don't know/Refused 17
reimpor <- dt %>% group_by(q28,party) %>%
filter(q28 == "Very important") %>%
summarise(frec = n())
reimpor
## Source: local data frame [6 x 3]
## Groups: q28 [?]
##
## q28 party frec
## <fctr> <fctr> <int>
## 1 Very important Republican 190
## 2 Very important Democrat 116
## 3 Very important Independent 149
## 4 Very important (VOL) No preference 25
## 5 Very important (VOL) Other party 2
## 6 Very important (VOL) Don't know/Refused 9
resomimpor <- dt %>% group_by(q28,party) %>%
filter(q28 == "Somewhat important") %>%
summarise(frec = n())
resomimpor
## Source: local data frame [6 x 3]
## Groups: q28 [?]
##
## q28 party frec
## <fctr> <fctr> <int>
## 1 Somewhat important Republican 174
## 2 Somewhat important Democrat 111
## 3 Somewhat important Independent 170
## 4 Somewhat important (VOL) No preference 23
## 5 Somewhat important (VOL) Other party 2
## 6 Somewhat important (VOL) Don't know/Refused 7
a <- ggplot(dt, aes(q25))
a + geom_bar(fill= 'deeppink2', colour='deeppink3')
b <- ggplot(dt, aes(q26))
b+ geom_bar(fill= 'cyan3', colour='cyan4')
c <- ggplot(dt, aes(q27))
c+ geom_bar(fill= 'seagreen1', colour='seagreen3')
d <- ggplot(dt, aes(q28))
d+ geom_bar(fill= 'lightseagreen', colour='cyan4')
rel <- dt %>% group_by(relig) %>%
summarise(frec = n())
rel #religion y su frecuencia
## # A tibble: 15 x 2
## relig
## <fctr>
## 1 Protestant (Baptist, Methodist, Non-denominational, Lutheran, Presbyterian,
## 2 Roman Catholic (Catholic)
## 3 Mormon (Church of Jesus Christ of Latter-day Saints/LDS)
## 4 Orthodox (Greek, Russian, or some other orthodox church)
## 5 Jewish (Judaism)
## 6 Muslim (Islam)
## 7 Buddhist
## 8 Hindu
## 9 Atheist (do not believe in God)
## 10 Agnostic (not sure if there is a God)
## 11 Something else (SPECIFY)
## 12 Nothing in particular
## 13 (VOL) Christian
## 14 (VOL) Unitarian (Universalist)
## 15 (VOL) Don't know/Refused
## # ... with 1 more variables: frec <int>
relde <- dt %>% group_by(relig,party) %>%
filter(party == "Democrat") %>%
summarise(frec = n())
relde #incidencia entre religión y los que son democráticos
## Source: local data frame [14 x 3]
## Groups: relig [?]
##
## relig
## <fctr>
## 1 Protestant (Baptist, Methodist, Non-denominational, Lutheran, Presbyterian,
## 2 Roman Catholic (Catholic)
## 3 Mormon (Church of Jesus Christ of Latter-day Saints/LDS)
## 4 Jewish (Judaism)
## 5 Muslim (Islam)
## 6 Buddhist
## 7 Hindu
## 8 Atheist (do not believe in God)
## 9 Agnostic (not sure if there is a God)
## 10 Something else (SPECIFY)
## 11 Nothing in particular
## 12 (VOL) Christian
## 13 (VOL) Unitarian (Universalist)
## 14 (VOL) Don't know/Refused
## # ... with 2 more variables: party <fctr>, frec <int>
relrep <- dt %>% group_by(relig,party) %>%
filter(party == "Republican") %>%
summarise(frec = n())
relrep #religion vrs republicanos
## Source: local data frame [14 x 3]
## Groups: relig [?]
##
## relig
## <fctr>
## 1 Protestant (Baptist, Methodist, Non-denominational, Lutheran, Presbyterian,
## 2 Roman Catholic (Catholic)
## 3 Mormon (Church of Jesus Christ of Latter-day Saints/LDS)
## 4 Orthodox (Greek, Russian, or some other orthodox church)
## 5 Jewish (Judaism)
## 6 Muslim (Islam)
## 7 Buddhist
## 8 Hindu
## 9 Atheist (do not believe in God)
## 10 Agnostic (not sure if there is a God)
## 11 Something else (SPECIFY)
## 12 Nothing in particular
## 13 (VOL) Christian
## 14 (VOL) Don't know/Refused
## # ... with 2 more variables: party <fctr>, frec <int>
relindep<- dt %>% group_by(relig,party) %>%
filter(party == "Independent") %>%
summarise(frec = n())
relindep #religion vrs independientes
## Source: local data frame [15 x 3]
## Groups: relig [?]
##
## relig
## <fctr>
## 1 Protestant (Baptist, Methodist, Non-denominational, Lutheran, Presbyterian,
## 2 Roman Catholic (Catholic)
## 3 Mormon (Church of Jesus Christ of Latter-day Saints/LDS)
## 4 Orthodox (Greek, Russian, or some other orthodox church)
## 5 Jewish (Judaism)
## 6 Muslim (Islam)
## 7 Buddhist
## 8 Hindu
## 9 Atheist (do not believe in God)
## 10 Agnostic (not sure if there is a God)
## 11 Something else (SPECIFY)
## 12 Nothing in particular
## 13 (VOL) Christian
## 14 (VOL) Unitarian (Universalist)
## 15 (VOL) Don't know/Refused
## # ... with 2 more variables: party <fctr>, frec <int>
print(summary(rel$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 8.0 18.0 40.0 133.9 152.5 696.0
sd(rel$frec)
## [1] 198.8368
print(summary(relde$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.00 5.25 17.50 42.36 55.00 181.00
sd(relde$frec)
## [1] 55.02392
print(summary(relindep$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.00 10.00 13.00 49.53 64.00 202.00
sd(relindep$frec)
## [1] 63.95966
print(summary(relrep$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.00 3.25 6.50 38.43 25.25 273.00
sd(relrep$frec)
## [1] 75.38793
print(summary(reinfluence$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.0 11.0 58.5 85.0 160.8 198.0
sd(reinfluence$frec)
## [1] 88.17709
print(summary(rething$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 11.00 27.25 189.50 211.30 389.20 449.00
sd(rething$frec)
## [1] 205.0314
print(summary(reimpor$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.00 13.00 70.50 81.83 140.80 190.00
sd(reimpor$frec)
## [1] 80.35774
print(summary(resomimpor$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.00 11.00 67.00 81.17 155.20 174.00
sd(resomimpor$frec)
## [1] 80.6856
ree <- dnorm(resomimpor$frec)
plot(ree)
h <- ggplot(dt, aes(factor(party)))
h + geom_bar(fill= 'cyan3', colour='cyan4')
hh <- dt %>% group_by(party) %>%
summarise(frec = n())
print(summary(hh$frec))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 14.00 48.25 311.50 334.80 579.20 743.00
sd(hh$frec)
## [1] 325.3241
plot(hh)
y si los queremos ver con porcentajes…
slices <- c(1, 2)
lbls <- c('Republican', 'Democrat')
pct <- round(slices/sum(slices)*100)
lbls<- paste(lbls, pct)
lbls <- paste(lbls, '%', sep='')
pie(slices, labels=lbls, col=rainbow(length(lbls)), radius = 1, labelcex=0.7,
main='Pie Chart of Party by %')
## Warning in text.default(1.1 * P$x, 1.1 * P$y, labels[i], xpd = TRUE, adj =
## ifelse(P$x < : "labelcex" is not a graphical parameter
## Warning in text.default(1.1 * P$x, 1.1 * P$y, labels[i], xpd = TRUE, adj =
## ifelse(P$x < : "labelcex" is not a graphical parameter
## Warning in title(main = main, ...): "labelcex" is not a graphical parameter
y de las 5 variables: relig, party, q27, state, attempt
boxplot(rel$frec)
boxplot(as.numeric(dt$party))
boxplot(as.numeric(dt$q27))
boxplot(as.numeric(dt$state))
boxplot(dt$attempt)
Si está sujeta a la ley de los grandes números. En los análisis de religión por partido político notamos que entre más delimitada esté la religión, más se dispersan los datos.