install.packages(“ggplot2”)

library(dplyr)
## 
## 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(readr)
library(foreign)
library(plyr)
## -------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## -------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
library(ggplot2)
library(RColorBrewer)
library(plotrix)
data <- read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/DATA S 2/Dec15/Dec15 public.sav", to.data.frame = TRUE)
## Warning in read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/
## DATA S 2/Dec15/Dec15 public.sav", : /Users/andreaosorio/Documents/Cuarto
## Semestre '16/DATA S 2/Dec15/Dec15 public.sav: Unrecognized record type 7,
## subtype 14 encountered in system file
## Warning in read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/
## DATA S 2/Dec15/Dec15 public.sav", : /Users/andreaosorio/Documents/Cuarto
## Semestre '16/DATA S 2/Dec15/Dec15 public.sav: Unrecognized record type 7,
## subtype 18 encountered in system file
## Warning in read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/
## DATA S 2/Dec15/Dec15 public.sav", : /Users/andreaosorio/Documents/Cuarto
## Semestre '16/DATA S 2/Dec15/Dec15 public.sav: Unrecognized record type 7,
## subtype 24 encountered in system file
data2 <- read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/DATA S 2/Jan16 public-2.sav",use.value.labels=TRUE, max.value.labels=TRUE, to.data.frame=TRUE)
## Warning in read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/
## DATA S 2/Jan16 public-2.sav", : /Users/andreaosorio/Documents/Cuarto
## Semestre '16/DATA S 2/Jan16 public-2.sav: Unrecognized record type 7,
## subtype 14 encountered in system file
## Warning in read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/
## DATA S 2/Jan16 public-2.sav", : /Users/andreaosorio/Documents/Cuarto
## Semestre '16/DATA S 2/Jan16 public-2.sav: Unrecognized record type 7,
## subtype 18 encountered in system file
## Warning in read.spss("/Users/andreaosorio/Documents/Cuarto Semestre '16/
## DATA S 2/Jan16 public-2.sav", : /Users/andreaosorio/Documents/Cuarto
## Semestre '16/DATA S 2/Jan16 public-2.sav: Unrecognized record type 7,
## subtype 24 encountered in system file
##¿Qué partido va delante en las encuestas?
#Para ello analizamos, las preguntas que responden directamente a la preferencia de los partidos.

#q44a.Which party could do a better job of, in dealing with the economy?

#Vemos la frecuencia de cada respuesta y asi la moda para ver el mayor. 
aeconomy <- count(data, "q44a")

attach(data)
moda<-function(q44a){
  frec.var<-table(q44a)
  valor<-which(frec.var==max(frec.var))  # Elementos con el valor
  names(valor)
}
moda(q44a)
## [1] "Republican Party"
#Podemos observar, que es el partido Republicano, con una freq de 688    

#Convertimos a numerico, para asi poder graficar, mas adelante. 
Partya <- as.numeric(data$q44a)
Partyb <- as.numeric(data$q44b)
Partyc <- as.numeric(data$q44c)

#q44b.Which party could do a better job of, in Dealing with the terrorist threat at home?
bterrorist <- count(data, "q44b")
attach(data)
## The following objects are masked from data (pos = 3):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
moda<-function(q44b){
  frec.var<-table(q44b)
  valor<-which(frec.var==max(frec.var))  
  names(valor)
}
moda(q44b)
## [1] "Republican Party"
#El partido republicano, es el favorito para tratar este porblema con una freq de 737.


#q44c. Which party could do a better job of,in Dealing with immigration?
cimmigra <- count(data, "q44c")

attach(data)
## The following objects are masked from data (pos = 3):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 4):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
moda<-function(q44c){
  frec.var<-table(q44c)
  valor<-which(frec.var==max(frec.var))  
  names(valor)
}
moda(q44c)
## [1] "Republican Party"
#El partido republicano, con una freq de 679. 

## Podemos discernir, que en ls aspectos con mayor preocupacion para un ciudadano de US, son cubiertos con mejor desempeño por parte del Partido Republicano. 
dealing <- ggplot(data, aes(factor(Partya, Partyb, Partyc))) 
lostres <- dealing + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Mejor trabajo con la Economia, Inmigrantes, Terrorismo") + xlab("Partidos") + ylab("Frecuencia Acumulada")

#Vemos, directamente la respuesta de los entrevistados al preguntarles su inclinacion individual del partido. 


#As of today do you lean more to the Republican Party or more to the Democratic Party?
data$party
##    [1] Republican                Republican               
##    [3] Democrat                  Republican               
##    [5] Independent               Democrat                 
##    [7] Republican                Independent              
##    [9] Independent               Independent              
##   [11] Independent               Independent              
##   [13] Independent               Democrat                 
##   [15] Independent               Independent              
##   [17] Other party (VOL.)        Republican               
##   [19] Democrat                  Independent              
##   [21] Democrat                  Independent              
##   [23] Independent               Don't know/Refused (VOL.)
##   [25] Republican                Democrat                 
##   [27] Independent               Independent              
##   [29] Democrat                  Democrat                 
##   [31] Democrat                  No preference (VOL.)     
##   [33] Independent               Independent              
##   [35] Democrat                  Democrat                 
##   [37] Republican                Democrat                 
##   [39] Independent               Independent              
##   [41] Republican                Democrat                 
##   [43] Republican                Republican               
##   [45] Democrat                  Independent              
##   [47] Republican                Democrat                 
##   [49] Independent               Independent              
##   [51] Republican                Democrat                 
##   [53] Independent               Independent              
##   [55] Democrat                  Democrat                 
##   [57] Republican                Independent              
##   [59] Independent               Independent              
##   [61] Independent               Independent              
##   [63] Democrat                  Democrat                 
##   [65] Democrat                  Republican               
##   [67] Republican                Republican               
##   [69] Independent               Democrat                 
##   [71] Republican                Republican               
##   [73] Democrat                  No preference (VOL.)     
##   [75] No preference (VOL.)      Republican               
##   [77] No preference (VOL.)      Republican               
##   [79] Republican                Democrat                 
##   [81] Independent               Independent              
##   [83] Republican                Republican               
##   [85] Don't know/Refused (VOL.) Republican               
##   [87] Republican                Democrat                 
##   [89] Independent               Independent              
##   [91] Democrat                  Independent              
##   [93] Democrat                  Democrat                 
##   [95] Independent               Republican               
##   [97] Independent               Republican               
##   [99] Republican                Democrat                 
##  [101] Independent               Republican               
##  [103] Independent               Democrat                 
##  [105] Democrat                  Independent              
##  [107] Other party (VOL.)        Don't know/Refused (VOL.)
##  [109] Democrat                  No preference (VOL.)     
##  [111] Democrat                  Democrat                 
##  [113] Independent               Democrat                 
##  [115] Republican                Democrat                 
##  [117] Independent               Independent              
##  [119] Democrat                  Independent              
##  [121] Democrat                  Don't know/Refused (VOL.)
##  [123] Democrat                  Independent              
##  [125] No preference (VOL.)      Republican               
##  [127] Democrat                  Republican               
##  [129] Democrat                  Independent              
##  [131] Republican                Republican               
##  [133] Independent               Democrat                 
##  [135] Republican                Independent              
##  [137] Democrat                  Independent              
##  [139] Independent               Independent              
##  [141] Independent               Independent              
##  [143] Independent               Democrat                 
##  [145] Independent               Republican               
##  [147] Democrat                  Republican               
##  [149] Independent               Independent              
##  [151] No preference (VOL.)      Democrat                 
##  [153] Democrat                  Democrat                 
##  [155] Democrat                  Republican               
##  [157] Independent               Democrat                 
##  [159] Republican                Republican               
##  [161] Other party (VOL.)        Democrat                 
##  [163] Republican                Republican               
##  [165] Independent               Republican               
##  [167] Republican                Independent              
##  [169] Republican                Democrat                 
##  [171] Republican                Democrat                 
##  [173] Republican                Democrat                 
##  [175] Democrat                  Republican               
##  [177] Independent               Independent              
##  [179] Democrat                  Republican               
##  [181] Democrat                  Republican               
##  [183] Democrat                  Independent              
##  [185] Democrat                  Independent              
##  [187] Republican                Republican               
##  [189] Independent               Democrat                 
##  [191] Democrat                  Don't know/Refused (VOL.)
##  [193] Democrat                  Republican               
##  [195] Other party (VOL.)        Independent              
##  [197] Republican                Democrat                 
##  [199] Independent               No preference (VOL.)     
##  [201] Republican                Independent              
##  [203] Republican                Democrat                 
##  [205] Independent               Independent              
##  [207] Democrat                  Independent              
##  [209] Independent               Democrat                 
##  [211] Democrat                  Republican               
##  [213] Democrat                  Republican               
##  [215] Democrat                  Republican               
##  [217] Democrat                  Democrat                 
##  [219] Republican                Republican               
##  [221] Republican                Independent              
##  [223] Republican                Independent              
##  [225] Independent               Republican               
##  [227] Republican                Republican               
##  [229] Independent               Republican               
##  [231] Independent               Independent              
##  [233] Democrat                  Independent              
##  [235] Republican                Independent              
##  [237] Independent               Independent              
##  [239] Democrat                  Republican               
##  [241] Republican                Republican               
##  [243] Democrat                  Republican               
##  [245] Republican                Democrat                 
##  [247] Democrat                  Democrat                 
##  [249] Democrat                  Other party (VOL.)       
##  [251] Independent               Democrat                 
##  [253] Independent               Democrat                 
##  [255] Republican                Democrat                 
##  [257] Democrat                  Independent              
##  [259] Democrat                  Democrat                 
##  [261] Democrat                  Independent              
##  [263] Independent               Democrat                 
##  [265] Republican                Republican               
##  [267] Democrat                  Republican               
##  [269] Independent               Democrat                 
##  [271] Republican                Independent              
##  [273] Republican                Independent              
##  [275] Democrat                  Democrat                 
##  [277] Republican                Democrat                 
##  [279] Independent               Independent              
##  [281] Democrat                  Independent              
##  [283] Republican                Independent              
##  [285] Republican                Democrat                 
##  [287] Democrat                  Republican               
##  [289] Democrat                  Independent              
##  [291] Independent               Independent              
##  [293] Independent               Republican               
##  [295] Independent               Republican               
##  [297] Independent               Independent              
##  [299] Republican                Democrat                 
##  [301] Independent               Republican               
##  [303] Independent               Independent              
##  [305] Republican                Democrat                 
##  [307] Democrat                  Democrat                 
##  [309] Republican                Democrat                 
##  [311] Republican                Democrat                 
##  [313] Independent               Independent              
##  [315] Republican                Republican               
##  [317] Republican                Republican               
##  [319] Democrat                  Democrat                 
##  [321] Republican                Independent              
##  [323] Republican                Independent              
##  [325] Republican                Republican               
##  [327] Don't know/Refused (VOL.) Democrat                 
##  [329] Independent               Democrat                 
##  [331] Independent               No preference (VOL.)     
##  [333] Independent               Democrat                 
##  [335] Democrat                  Democrat                 
##  [337] Independent               Independent              
##  [339] Democrat                  Independent              
##  [341] Independent               Independent              
##  [343] Republican                Democrat                 
##  [345] Republican                Independent              
##  [347] Independent               Republican               
##  [349] Republican                Democrat                 
##  [351] Independent               Democrat                 
##  [353] Independent               Republican               
##  [355] Democrat                  Republican               
##  [357] Democrat                  Independent              
##  [359] Independent               Democrat                 
##  [361] Independent               Independent              
##  [363] Democrat                  No preference (VOL.)     
##  [365] Republican                Republican               
##  [367] Independent               Republican               
##  [369] No preference (VOL.)      Democrat                 
##  [371] Republican                Republican               
##  [373] Republican                Independent              
##  [375] Republican                Democrat                 
##  [377] Republican                Democrat                 
##  [379] Democrat                  Democrat                 
##  [381] No preference (VOL.)      Independent              
##  [383] Republican                Democrat                 
##  [385] Democrat                  Democrat                 
##  [387] Independent               Independent              
##  [389] Republican                Democrat                 
##  [391] Independent               Independent              
##  [393] Republican                Republican               
##  [395] Democrat                  Republican               
##  [397] Republican                Democrat                 
##  [399] Independent               Independent              
##  [401] Democrat                  Democrat                 
##  [403] Democrat                  Democrat                 
##  [405] Democrat                  Independent              
##  [407] Independent               Independent              
##  [409] Republican                Independent              
##  [411] Republican                Democrat                 
##  [413] Democrat                  Independent              
##  [415] Independent               Independent              
##  [417] Republican                Democrat                 
##  [419] Democrat                  Democrat                 
##  [421] Democrat                  Democrat                 
##  [423] Republican                Republican               
##  [425] Democrat                  Republican               
##  [427] No preference (VOL.)      Republican               
##  [429] Independent               Democrat                 
##  [431] Democrat                  Independent              
##  [433] Republican                Republican               
##  [435] Republican                Democrat                 
##  [437] Independent               Independent              
##  [439] Independent               No preference (VOL.)     
##  [441] Independent               Republican               
##  [443] Democrat                  Independent              
##  [445] Independent               Independent              
##  [447] Democrat                  Independent              
##  [449] Independent               Independent              
##  [451] Independent               Republican               
##  [453] Democrat                  Independent              
##  [455] Republican                Democrat                 
##  [457] Republican                Independent              
##  [459] Republican                Democrat                 
##  [461] Republican                Independent              
##  [463] Independent               Republican               
##  [465] Independent               Republican               
##  [467] Democrat                  Republican               
##  [469] Republican                Don't know/Refused (VOL.)
##  [471] Republican                Independent              
##  [473] Independent               Republican               
##  [475] Democrat                  No preference (VOL.)     
##  [477] Republican                Republican               
##  [479] Republican                Republican               
##  [481] Republican                Republican               
##  [483] Republican                Republican               
##  [485] Don't know/Refused (VOL.) Democrat                 
##  [487] Independent               Independent              
##  [489] Democrat                  Independent              
##  [491] Republican                Independent              
##  [493] Democrat                  Independent              
##  [495] Republican                Independent              
##  [497] Independent               Democrat                 
##  [499] Democrat                  Democrat                 
##  [501] Independent               Republican               
##  [503] Republican                Republican               
##  [505] Don't know/Refused (VOL.) Independent              
##  [507] Independent               Democrat                 
##  [509] Republican                Independent              
##  [511] Independent               Republican               
##  [513] Democrat                  Democrat                 
##  [515] Independent               Republican               
##  [517] Republican                Democrat                 
##  [519] Independent               Democrat                 
##  [521] Independent               Independent              
##  [523] Independent               Republican               
##  [525] Democrat                  Republican               
##  [527] Democrat                  No preference (VOL.)     
##  [529] Independent               Republican               
##  [531] Independent               Independent              
##  [533] Democrat                  Independent              
##  [535] Independent               Democrat                 
##  [537] Independent               Independent              
##  [539] Independent               Democrat                 
##  [541] Republican                Independent              
##  [543] Independent               Independent              
##  [545] Independent               Independent              
##  [547] Independent               Democrat                 
##  [549] Independent               Independent              
##  [551] Democrat                  Democrat                 
##  [553] Republican                Republican               
##  [555] Independent               Independent              
##  [557] Independent               Independent              
##  [559] Other party (VOL.)        Independent              
##  [561] Independent               Independent              
##  [563] Independent               Republican               
##  [565] No preference (VOL.)      Independent              
##  [567] Republican                Independent              
##  [569] Independent               Democrat                 
##  [571] Republican                Republican               
##  [573] Democrat                  Independent              
##  [575] Republican                Republican               
##  [577] Independent               Republican               
##  [579] Democrat                  Democrat                 
##  [581] Independent               Democrat                 
##  [583] Independent               Republican               
##  [585] Democrat                  Independent              
##  [587] Other party (VOL.)        Republican               
##  [589] Independent               Democrat                 
##  [591] Republican                Independent              
##  [593] Independent               Democrat                 
##  [595] Republican                Republican               
##  [597] Democrat                  Independent              
##  [599] Republican                Republican               
##  [601] Democrat                  Democrat                 
##  [603] Democrat                  Democrat                 
##  [605] Republican                No preference (VOL.)     
##  [607] Republican                Independent              
##  [609] Democrat                  Democrat                 
##  [611] Democrat                  Independent              
##  [613] Independent               Democrat                 
##  [615] Independent               Independent              
##  [617] Democrat                  Independent              
##  [619] Independent               Republican               
##  [621] Republican                Republican               
##  [623] Independent               Independent              
##  [625] Democrat                  Democrat                 
##  [627] Independent               Don't know/Refused (VOL.)
##  [629] Republican                Independent              
##  [631] Democrat                  Republican               
##  [633] Independent               Republican               
##  [635] Republican                Republican               
##  [637] Republican                Republican               
##  [639] Republican                Republican               
##  [641] Independent               Republican               
##  [643] Independent               Independent              
##  [645] Democrat                  Republican               
##  [647] Independent               Independent              
##  [649] Independent               Democrat                 
##  [651] Independent               Independent              
##  [653] Independent               Republican               
##  [655] Democrat                  Democrat                 
##  [657] Independent               Independent              
##  [659] Democrat                  Democrat                 
##  [661] Independent               Democrat                 
##  [663] Democrat                  Republican               
##  [665] Independent               Republican               
##  [667] Independent               Republican               
##  [669] Independent               Republican               
##  [671] Independent               Republican               
##  [673] Independent               Republican               
##  [675] Other party (VOL.)        Republican               
##  [677] Independent               Democrat                 
##  [679] Independent               Democrat                 
##  [681] Democrat                  Democrat                 
##  [683] Democrat                  Independent              
##  [685] Independent               Independent              
##  [687] Democrat                  Republican               
##  [689] Republican                Independent              
##  [691] No preference (VOL.)      Republican               
##  [693] Independent               Democrat                 
##  [695] Independent               Democrat                 
##  [697] Republican                Independent              
##  [699] Republican                Republican               
##  [701] Republican                Independent              
##  [703] Independent               Independent              
##  [705] Independent               Republican               
##  [707] Independent               Democrat                 
##  [709] Republican                Independent              
##  [711] Independent               Independent              
##  [713] Republican                Independent              
##  [715] Independent               Republican               
##  [717] Democrat                  Democrat                 
##  [719] Republican                Independent              
##  [721] Democrat                  Independent              
##  [723] Republican                Democrat                 
##  [725] Democrat                  Independent              
##  [727] Democrat                  Democrat                 
##  [729] No preference (VOL.)      Independent              
##  [731] Democrat                  Independent              
##  [733] Democrat                  Democrat                 
##  [735] Independent               Independent              
##  [737] Independent               Don't know/Refused (VOL.)
##  [739] Independent               Democrat                 
##  [741] Independent               Republican               
##  [743] Independent               Independent              
##  [745] Independent               Independent              
##  [747] Independent               Republican               
##  [749] Republican                Democrat                 
##  [751] Democrat                  Independent              
##  [753] No preference (VOL.)      Independent              
##  [755] Republican                Republican               
##  [757] Independent               Independent              
##  [759] Republican                Republican               
##  [761] No preference (VOL.)      No preference (VOL.)     
##  [763] Democrat                  Democrat                 
##  [765] Democrat                  No preference (VOL.)     
##  [767] Democrat                  Republican               
##  [769] Independent               Republican               
##  [771] Democrat                  Democrat                 
##  [773] Republican                Democrat                 
##  [775] Independent               Democrat                 
##  [777] Independent               Don't know/Refused (VOL.)
##  [779] Democrat                  Independent              
##  [781] Democrat                  No preference (VOL.)     
##  [783] Democrat                  Independent              
##  [785] Independent               Republican               
##  [787] Republican                Don't know/Refused (VOL.)
##  [789] Democrat                  Independent              
##  [791] Independent               Democrat                 
##  [793] Democrat                  No preference (VOL.)     
##  [795] Republican                Democrat                 
##  [797] Republican                Independent              
##  [799] Democrat                  Independent              
##  [801] Democrat                  No preference (VOL.)     
##  [803] Independent               Democrat                 
##  [805] Independent               Democrat                 
##  [807] Republican                Republican               
##  [809] No preference (VOL.)      Independent              
##  [811] Independent               Democrat                 
##  [813] Democrat                  Independent              
##  [815] Independent               Republican               
##  [817] Republican                Democrat                 
##  [819] Republican                Republican               
##  [821] Republican                Republican               
##  [823] Democrat                  Independent              
##  [825] Independent               Democrat                 
##  [827] Republican                Republican               
##  [829] Independent               Democrat                 
##  [831] Independent               Democrat                 
##  [833] Independent               Republican               
##  [835] Independent               Independent              
##  [837] Republican                Republican               
##  [839] Independent               Democrat                 
##  [841] Republican                Democrat                 
##  [843] Independent               Democrat                 
##  [845] Independent               Republican               
##  [847] Don't know/Refused (VOL.) Republican               
##  [849] Democrat                  Independent              
##  [851] Independent               Independent              
##  [853] Independent               Democrat                 
##  [855] Republican                Independent              
##  [857] Independent               Democrat                 
##  [859] Republican                Republican               
##  [861] Independent               Republican               
##  [863] Democrat                  Independent              
##  [865] Independent               Republican               
##  [867] Republican                Independent              
##  [869] Independent               Independent              
##  [871] Independent               No preference (VOL.)     
##  [873] Independent               Independent              
##  [875] Independent               Republican               
##  [877] Democrat                  Democrat                 
##  [879] Democrat                  Independent              
##  [881] Republican                Independent              
##  [883] Independent               Republican               
##  [885] Independent               Independent              
##  [887] Republican                Independent              
##  [889] Independent               Democrat                 
##  [891] Republican                Independent              
##  [893] Independent               Republican               
##  [895] Democrat                  Republican               
##  [897] Independent               Democrat                 
##  [899] Independent               Independent              
##  [901] Democrat                  Independent              
##  [903] Democrat                  Democrat                 
##  [905] Independent               Independent              
##  [907] Democrat                  Republican               
##  [909] Independent               Democrat                 
##  [911] Democrat                  Independent              
##  [913] Republican                Republican               
##  [915] No preference (VOL.)      No preference (VOL.)     
##  [917] Independent               Democrat                 
##  [919] Independent               Republican               
##  [921] Independent               Independent              
##  [923] Independent               Democrat                 
##  [925] Democrat                  Independent              
##  [927] Republican                Democrat                 
##  [929] Republican                Republican               
##  [931] Republican                Independent              
##  [933] Democrat                  Independent              
##  [935] Democrat                  Independent              
##  [937] Independent               Independent              
##  [939] Independent               Democrat                 
##  [941] Democrat                  Republican               
##  [943] Republican                Democrat                 
##  [945] Republican                Democrat                 
##  [947] Democrat                  No preference (VOL.)     
##  [949] Independent               Republican               
##  [951] Democrat                  Republican               
##  [953] Republican                Independent              
##  [955] Independent               Independent              
##  [957] Independent               Republican               
##  [959] Democrat                  Independent              
##  [961] Democrat                  Republican               
##  [963] Democrat                  Democrat                 
##  [965] Democrat                  Democrat                 
##  [967] Democrat                  Independent              
##  [969] Independent               Independent              
##  [971] Republican                Independent              
##  [973] Independent               Republican               
##  [975] Democrat                  Democrat                 
##  [977] Independent               Independent              
##  [979] Independent               Republican               
##  [981] Democrat                  Independent              
##  [983] Independent               Democrat                 
##  [985] Independent               Republican               
##  [987] Independent               Democrat                 
##  [989] Republican                Republican               
##  [991] Republican                No preference (VOL.)     
##  [993] Independent               Republican               
##  [995] Don't know/Refused (VOL.) Independent              
##  [997] Democrat                  Democrat                 
##  [999] Independent               Democrat                 
## [1001] Democrat                  No preference (VOL.)     
## [1003] Democrat                  Independent              
## [1005] Republican                Republican               
## [1007] Independent               Democrat                 
## [1009] Democrat                  Democrat                 
## [1011] Independent               Democrat                 
## [1013] Independent               Republican               
## [1015] Democrat                  Independent              
## [1017] Republican                Independent              
## [1019] Republican                Independent              
## [1021] Independent               Republican               
## [1023] No preference (VOL.)      Democrat                 
## [1025] Democrat                  Democrat                 
## [1027] Republican                Democrat                 
## [1029] Independent               Democrat                 
## [1031] Republican                Republican               
## [1033] Don't know/Refused (VOL.) Republican               
## [1035] Independent               Independent              
## [1037] Democrat                  Democrat                 
## [1039] Independent               Republican               
## [1041] Independent               Don't know/Refused (VOL.)
## [1043] Republican                Democrat                 
## [1045] Independent               Independent              
## [1047] Democrat                  Democrat                 
## [1049] Republican                Independent              
## [1051] Democrat                  Democrat                 
## [1053] Democrat                  Independent              
## [1055] Republican                Independent              
## [1057] Independent               Republican               
## [1059] Independent               Democrat                 
## [1061] Independent               Republican               
## [1063] Republican                Independent              
## [1065] Democrat                  Republican               
## [1067] Independent               Republican               
## [1069] Democrat                  Republican               
## [1071] Republican                Republican               
## [1073] Democrat                  Independent              
## [1075] Republican                Republican               
## [1077] Democrat                  Independent              
## [1079] Republican                Independent              
## [1081] Independent               Democrat                 
## [1083] Democrat                  Republican               
## [1085] Republican                Independent              
## [1087] Republican                Independent              
## [1089] Republican                Don't know/Refused (VOL.)
## [1091] Democrat                  Republican               
## [1093] Democrat                  Republican               
## [1095] Independent               Independent              
## [1097] Democrat                  Democrat                 
## [1099] Don't know/Refused (VOL.) Republican               
## [1101] Independent               Republican               
## [1103] Independent               Independent              
## [1105] Democrat                  Republican               
## [1107] Democrat                  Republican               
## [1109] Republican                Democrat                 
## [1111] Democrat                  Democrat                 
## [1113] Independent               Democrat                 
## [1115] Independent               Independent              
## [1117] Republican                Independent              
## [1119] Democrat                  Republican               
## [1121] Independent               Republican               
## [1123] Democrat                  Democrat                 
## [1125] No preference (VOL.)      Independent              
## [1127] Independent               Independent              
## [1129] Independent               Democrat                 
## [1131] Democrat                  Independent              
## [1133] Democrat                  Independent              
## [1135] Independent               Republican               
## [1137] Independent               Republican               
## [1139] Democrat                  Democrat                 
## [1141] Democrat                  Republican               
## [1143] Democrat                  Don't know/Refused (VOL.)
## [1145] Independent               Republican               
## [1147] Republican                Democrat                 
## [1149] Independent               Republican               
## [1151] Independent               Republican               
## [1153] Independent               Democrat                 
## [1155] Democrat                  Independent              
## [1157] Don't know/Refused (VOL.) Democrat                 
## [1159] Republican                Independent              
## [1161] No preference (VOL.)      Don't know/Refused (VOL.)
## [1163] Republican                Independent              
## [1165] Independent               Republican               
## [1167] Democrat                  Independent              
## [1169] Independent               Democrat                 
## [1171] Republican                Independent              
## [1173] Republican                Independent              
## [1175] Independent               Democrat                 
## [1177] Independent               Independent              
## [1179] Democrat                  Independent              
## [1181] Democrat                  Democrat                 
## [1183] Independent               Republican               
## [1185] Democrat                  Republican               
## [1187] Democrat                  Independent              
## [1189] Democrat                  Democrat                 
## [1191] Democrat                  Independent              
## [1193] Republican                Independent              
## [1195] Independent               Independent              
## [1197] Democrat                  Independent              
## [1199] Republican                Independent              
## [1201] Republican                Independent              
## [1203] Independent               Independent              
## [1205] Independent               Democrat                 
## [1207] Democrat                  Republican               
## [1209] Democrat                  Democrat                 
## [1211] Independent               Republican               
## [1213] Republican                Republican               
## [1215] Independent               Democrat                 
## [1217] Republican                Republican               
## [1219] Democrat                  Democrat                 
## [1221] Republican                Independent              
## [1223] Democrat                  Democrat                 
## [1225] Independent               Democrat                 
## [1227] Republican                Republican               
## [1229] Independent               Democrat                 
## [1231] Democrat                  Independent              
## [1233] Independent               Republican               
## [1235] Independent               Democrat                 
## [1237] Republican                Independent              
## [1239] Democrat                  Independent              
## [1241] Independent               Democrat                 
## [1243] Democrat                  Independent              
## [1245] Republican                Republican               
## [1247] Democrat                  Republican               
## [1249] Republican                Republican               
## [1251] Democrat                  Democrat                 
## [1253] Independent               Independent              
## [1255] Republican                Independent              
## [1257] Democrat                  Independent              
## [1259] Independent               Republican               
## [1261] Republican                Republican               
## [1263] Independent               Republican               
## [1265] Republican                Democrat                 
## [1267] No preference (VOL.)      Democrat                 
## [1269] Democrat                  Republican               
## [1271] Independent               Independent              
## [1273] Republican                Independent              
## [1275] Democrat                  Republican               
## [1277] Independent               No preference (VOL.)     
## [1279] Independent               Independent              
## [1281] Democrat                  Independent              
## [1283] Democrat                  Democrat                 
## [1285] Republican                Democrat                 
## [1287] Republican                Democrat                 
## [1289] Independent               Independent              
## [1291] Democrat                  Republican               
## [1293] Independent               Republican               
## [1295] Independent               Independent              
## [1297] Independent               Other party (VOL.)       
## [1299] Democrat                  Republican               
## [1301] Republican                Democrat                 
## [1303] Democrat                  Independent              
## [1305] Republican                Independent              
## [1307] Independent               Democrat                 
## [1309] Independent               Don't know/Refused (VOL.)
## [1311] Independent               Independent              
## [1313] Independent               Independent              
## [1315] Independent               No preference (VOL.)     
## [1317] Democrat                  Democrat                 
## [1319] Independent               Independent              
## [1321] Democrat                  Republican               
## [1323] No preference (VOL.)      Independent              
## [1325] Democrat                  Republican               
## [1327] No preference (VOL.)      Republican               
## [1329] Independent               Republican               
## [1331] Independent               Republican               
## [1333] Democrat                  Republican               
## [1335] Republican                Republican               
## [1337] Democrat                  Independent              
## [1339] Democrat                  Democrat                 
## [1341] Democrat                  Republican               
## [1343] Independent               Democrat                 
## [1345] Independent               Independent              
## [1347] Democrat                  Independent              
## [1349] Democrat                  Republican               
## [1351] Republican                Democrat                 
## [1353] Democrat                  Democrat                 
## [1355] Republican                Democrat                 
## [1357] Republican                Republican               
## [1359] Independent               Independent              
## [1361] Independent               Democrat                 
## [1363] Independent               Independent              
## [1365] Independent               Democrat                 
## [1367] Democrat                  Independent              
## [1369] Republican                Don't know/Refused (VOL.)
## [1371] Republican                Democrat                 
## [1373] Independent               Democrat                 
## [1375] Independent               Democrat                 
## [1377] Republican                Democrat                 
## [1379] Democrat                  Republican               
## [1381] Independent               Independent              
## [1383] Independent               No preference (VOL.)     
## [1385] Democrat                  Republican               
## [1387] Independent               Independent              
## [1389] Independent               Democrat                 
## [1391] Independent               Republican               
## [1393] Independent               Independent              
## [1395] Democrat                  No preference (VOL.)     
## [1397] Independent               Independent              
## [1399] Democrat                  Democrat                 
## [1401] Independent               Republican               
## [1403] Independent               Republican               
## [1405] Independent               Republican               
## [1407] Independent               Independent              
## [1409] Democrat                  Independent              
## [1411] Independent               Independent              
## [1413] Democrat                  Democrat                 
## [1415] Independent               No preference (VOL.)     
## [1417] Democrat                  Independent              
## [1419] Independent               Independent              
## [1421] Democrat                  Republican               
## [1423] Republican                Independent              
## [1425] Independent               Republican               
## [1427] Republican                Republican               
## [1429] Republican                Independent              
## [1431] Independent               Republican               
## [1433] Democrat                  Republican               
## [1435] Republican                Independent              
## [1437] Republican                Independent              
## [1439] Democrat                  Democrat                 
## [1441] Republican                Independent              
## [1443] Democrat                  Democrat                 
## [1445] Independent               Independent              
## [1447] Republican                Independent              
## [1449] Republican                Independent              
## [1451] Independent               Independent              
## [1453] Independent               Republican               
## [1455] Democrat                  Democrat                 
## [1457] Independent               Independent              
## [1459] Democrat                  Independent              
## [1461] Democrat                  Democrat                 
## [1463] Democrat                  Democrat                 
## [1465] Democrat                  Democrat                 
## [1467] Republican                Republican               
## [1469] Independent               Republican               
## [1471] Independent               Republican               
## [1473] Independent               Independent              
## [1475] Republican                Democrat                 
## [1477] Independent               Republican               
## [1479] Democrat                  Independent              
## [1481] Democrat                  Independent              
## [1483] Republican                Independent              
## [1485] Republican                Democrat                 
## [1487] Democrat                  No preference (VOL.)     
## [1489] Democrat                  No preference (VOL.)     
## [1491] Independent               Independent              
## [1493] Independent               Democrat                 
## [1495] Republican                Democrat                 
## [1497] Republican                No preference (VOL.)     
## [1499] Independent               Democrat                 
## 6 Levels: Republican Democrat Independent ... Don't know/Refused (VOL.)
count(data, "party")
##                       party freq
## 1                Republican  416
## 2                  Democrat  446
## 3               Independent  557
## 4      No preference (VOL.)   48
## 5        Other party (VOL.)    9
## 6 Don't know/Refused (VOL.)   24
attach(data)
## The following objects are masked from data (pos = 3):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 4):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 5):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
moda<-function(party){
  frec.var<-table(party)
  valor<-which(frec.var==max(frec.var))  # Elementos con el valor
  names(valor)
}
moda(party)
## [1] "Independent"
#La mayoria se considera, Independiente, y con una n de 446 los ciudadanos se consideraban Democratas y 416 Republicanos.


a <- ggplot(data, aes(factor(Partya))) 
b <- ggplot(data, aes(factor(Partyb)))
c <- ggplot(data, aes(factor(Partyc)))

economia <- a + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Trabajo del Partido Lideando con la Economia") + xlab("Partidos") + ylab("Frecuencia") 

terrorist <- b + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Trabajo del Partido Lideando con el Terrorismo") + xlab("Partidos") + ylab("Frecuencia") 

immigration <- c + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Trabajo del Partido Lideando con el Terrorismo") + xlab("Partidos") + ylab("Frecuencia") 
#Analizaremos ahora un mes despues si hay un sesgo en las respuestas

#As of today do you lean more to the Republican Party or more to the Democratic Party? 
partylnna <- data2$partyln[!is.na(data2$partyln)]

count(data2, "partylnna")
##   partylnna freq
## 1         1  311
## 2         2  321
## 3         9  246
#Removemos los NA para poder analizar mejor. 

#1 = significa Republicanos, y 2 = significa Democratas. 

attach(data2)
## The following objects are masked from data (pos = 3):
## 
##     age, attempt, attend, birth_hisp, born, cellweight, chr,
##     cregion, density, fcall, form, hh1, hh3, hisp, ideo, ilang,
##     income, int_date, money2, party, partyln, q1, q20, q22a, q22b,
##     q22c, q22d, q22e, q25, q26, q27, qc1, ql1, ql1a, qs1, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, usr, weight
## The following objects are masked from data (pos = 4):
## 
##     age, attempt, attend, birth_hisp, born, cellweight, chr,
##     cregion, density, fcall, form, hh1, hh3, hisp, ideo, ilang,
##     income, int_date, money2, party, partyln, q1, q20, q22a, q22b,
##     q22c, q22d, q22e, q25, q26, q27, qc1, ql1, ql1a, qs1, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, usr, weight
## The following objects are masked from data (pos = 5):
## 
##     age, attempt, attend, birth_hisp, born, cellweight, chr,
##     cregion, density, fcall, form, hh1, hh3, hisp, ideo, ilang,
##     income, int_date, money2, party, partyln, q1, q20, q22a, q22b,
##     q22c, q22d, q22e, q25, q26, q27, qc1, ql1, ql1a, qs1, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, usr, weight
## The following objects are masked from data (pos = 6):
## 
##     age, attempt, attend, birth_hisp, born, cellweight, chr,
##     cregion, density, fcall, form, hh1, hh3, hisp, ideo, ilang,
##     income, int_date, money2, party, partyln, q1, q20, q22a, q22b,
##     q22c, q22d, q22e, q25, q26, q27, qc1, ql1, ql1a, qs1, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, usr, weight
moda<-function(partylnna){
  frec.var<-table(partylnna)
  valor<-which(frec.var==max(frec.var))  # Elementos con el valor
  names(valor)
}
moda(partylnna)
## [1] "2"
##El partido Democrata es el que mas votantes tiene inclinados hacia el, con 321. 

#GRAFICA PIE de inclinacion partido parltlyna, O HIST. 
slices <- c(321, 311)
lbls <- c("Republicano", "Democrata")
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct)
lbls <- paste(lbls, "%", sep = " ")
lp <- pie3D(radius = 2, slices, labels = lbls, explode = 0.5, main = "Inclinacion/Preferencia", col = c("skyblue", "pink"), labelcex = 0.8)

#In politicsTODAY, do you consider yourself a Republican, Democrat, or Independet?
count(data2, "party")
##   party freq
## 1     1  538
## 2     2  593
## 3     3  743
## 4     4   85
## 5     5   14
## 6     9   36
##Podemos observar que el partido con mayor freq es el Democrata con 593 ciudadanos. 

#GRAFICA PIE de como se clasifica asi mismo el CIUDADANO. party

slice <- c(538, 593)
labe <- c("Republicano", "Democrata")
pctt <- round(slice/sum(slice)*100)
labe <- paste(labe, pctt)
labe <- paste(labe, "%", sep = " ")
lpp <- pie3D(radius = 2, slice, labels = labe, explode = 0.1, main = "Pertenencia Ciudadano", col = c("skyblue", "pink"), labelcex = 0.8)

#Q21. Thinking ahead to the presidential election, that will take place in NOv 2016, regardless of who nomiees from each party are, do you think you will[categories]?
#1 Definitely vote for the Republican 
#2 Probably vote for the Republican
#3 Probaby vote for the Democrat
#4 Definitely vote for the Democrat
#5 Other/neither
# 6 Too early to say
# 9 Refused 

count(data2, "q21")
##   q21 freq
## 1   1  479
## 2   2  317
## 3   3  328
## 4   4  497
## 5   5  142
## 6   6  131
## 7   9  115
moda(q21)
## [1] "4"
##Vemos que "Definitivamente votare por el Democrata" es el que mayor frecuencia posee con 497, y es seguido por el "Definitely vote for the Republican" con 479
#GRAFICA PIE, O HIST. 

slic <- c(479, 317, 328, 497, 388)
labb <- c("                               Def Rep", "ProbRep", "Prob Demc", "Def Demc", "                      Other")
pcttt <- round(slic/sum(slic)*100)
labb <- paste(labb, pcttt)
labb <- paste(labb, "%", sep = "")
lppp <- pie3D(radius = 2, slic, labels = labb, explode = 0.48, labelcex = 1, main = "Asignacion del Ciudadano hacia Su Pertenencia del Partido", col = c("skyblue", "pink", "orange", "green","yellow"))

#lOS DEFINITIVOS. 
pedazo <- c(479, 497,1033)
titulo <- c("                               Def Rep",      "Def Demc", "Other")
forma <- round(pedazo/sum(pedazo)*100)
titulo <- paste(titulo, forma)
titulo <- paste(titulo, "%", sep = " ")
pie <- pie3D(radius = 2, pedazo, labels = titulo, explode = 0.3, labelcex = 1, main = "Asignacion del Ciudadano hacia Su Pertenencia del Partido", col = c( "orange", "green","skyblue"))

#q.22 Regardless of who you currently support, I’d like to know what kind of president you think each of the following would be if elected in November 2016? First, [ NAME]. If [NAME] were to become president do you think (he/she) would be a great, good, average, poor, or terrible president?  How about if [NEXT ITEM] were to be come president? [IF NECESSARY:do you think he/she would be a great,good, average,poor,or terrible president?

#a. Ben Carson
#b. Bernie Sanders
#c. Chris Christie
#d. Donald Trump
#e. Hillary Clinton
#f. Jeb Bush
#g. John Kasich [PRONOUNCED: “KAY-sick”]
#h. Marco Rubio
#i. Ted Cruz

#RESPONSE CATEGORIES:
#1 Great president
#2 Good president
#3 Average president
#4 Poor president
#5 Terrible president
#8 Never heard of candidate (VOL.)
#9 Don’t know/Refused (VOL.)

#Tomaremos a los dos candidatos mas fuertes. 
#Donald Trump = d
count(data2, "q22d")
##   q22d freq
## 1    1  199
## 2    2  386
## 3    3  246
## 4    4  307
## 5    5  783
## 6    8   11
## 7    9   77
#q22d, Donald Trump, 783 persons said he would be a Terrible , and 386 persons said he'll be a Good President.

#Podemos observarlo graficamente. Con un Grafico de barras.
trump <- as.numeric(data2$q22d)
ggplot(data2, aes(factor(trump))) + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Opinion de que Trump sera Buen Presidente") + xlab("De Excelente a Peor Eleccion ") + ylab("Frecuencia")

#Podemos observar graficamente, que la maypr freq pertenece a el numero 5, el cual es la categoria de "Terrible President". 


#Hillary Clinton = e
count(data2, "q22e")
##   q22e freq
## 1    1  226
## 2    2  521
## 3    3  365
## 4    4  315
## 5    5  534
## 6    8    5
## 7    9   43
#q22e, Hillary Clinton, 543 said she would be a POOR President, and 521 said she would be a good president.


clinton <- as.numeric(data2$q22e)
ggplot(data2, aes(factor(clinton))) + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Opinion de que Clinton sera Buen Presidente") + xlab("De Excelente a Peor Eleccion ") + ylab("Frecuencia")

#Graficamente podemos observar, que la mayoria de ciudadanos opina que Hillary Clinton es "Good President", y con una minima diferencia opinan que es "Una Terrible Presidente". Podemos observar asi una distribucion mas equivalente entre dos criterios hacia su persona.     
## POR ENDE, el Partido Democrata, el cual tiene como representante a H. Clynton, tiene una mayor posibilidad de quedar electa, ya que el partido democrata directamente tiene mas individuos los cuales apoyan esta ideologia, sino tambien en los tres aspoectos demayor indole nacional a la oponion del ciudadano han sido mejor cubiertas por el partido democrata, y directamente H. Clynton es considerada como una "buena candidata"
# El futuro Presidente de USA, depende del voto de la clase social la cual contenga mayor cantidad; de acuerdo a este premisa, Quien será?


#q62 In general, do you think the Republican Party favors the rich, favors the middle class or favors the poor?
count(data, "q62")
##                              q62 freq
## 1                Favors the rich  898
## 2        Favors the middle class  427
## 3                Favors the poor   27
## 4 Favors none/all equally (VOL.)   77
## 5      Don't know/Refused (VOL.)   71
attach(data)
## The following objects are masked from data2:
## 
##     age, attempt, attend, birth_hisp, born, cellweight, chr,
##     cregion, density, fcall, form, hh1, hh3, hisp, ideo, ilang,
##     income, int_date, money2, party, partyln, q1, q20, q22a, q22b,
##     q22c, q22d, q22e, q25, q26, q27, qc1, ql1, ql1a, qs1, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, usr, weight
## The following objects are masked from data (pos = 4):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 5):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 6):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 7):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
moda<-function(q62){
  frec.var<-table(q62)
  valor<-which(frec.var==max(frec.var))  # Elementos con el valor
  names(valor)
}
moda(q62)
## [1] "Favors the rich"
#898 votantes opinan, que el partido Republicano favorece solo a las personas ricas, y una minoria con 27 votantes opinan que favorece a los pobres. Y la clase media con una freq de  427


#q63. In general, do you think the Democratic Party favors the rich, favors the middle class or favors the poor?
count(data, "q63")
##                              q63 freq
## 1                Favors the rich  382
## 2        Favors the middle class  456
## 3                Favors the poor  492
## 4 Favors none/all equally (VOL.)   81
## 5      Don't know/Refused (VOL.)   89
attach(data)
## The following objects are masked from data (pos = 3):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data2:
## 
##     age, attempt, attend, birth_hisp, born, cellweight, chr,
##     cregion, density, fcall, form, hh1, hh3, hisp, ideo, ilang,
##     income, int_date, money2, party, partyln, q1, q20, q22a, q22b,
##     q22c, q22d, q22e, q25, q26, q27, qc1, ql1, ql1a, qs1, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, usr, weight
## The following objects are masked from data (pos = 5):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 6):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 7):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
## The following objects are masked from data (pos = 8):
## 
##     OFFER2_FINAL, Q7VB0, age, attempt, attend, birth_hisp, born,
##     cellmin, cellweight, chr, cregion, density, educ2, fcall,
##     form, hh1, hh3, hisp, ideo, igender, ilang, income, int_date,
##     irace, llitext0, llweight, money2, money2token, offer2, party,
##     partyln, phoneuse, phoneuse2, psraid, q1, q11a, q11b, q11c,
##     q15a, q15b, q15c, q15d, q15e, q16, q2, q20, q22a, q22b, q22c,
##     q22d, q22e, q23, q24, q25, q26, q27, q28a, q28b, q28c, q28d,
##     q28e, q30a, q30b, q30c, q30d, q30e, q31, q40, q41, q42, q43,
##     q44a, q44b, q44c, q44d, q44ef1, q44ff2, q45, q45a, q45z,
##     q46f1, q47f2, q48a, q48b, q48c, q48hf1, q48if2, q51a, q51b,
##     q51c, q51d, q51e, q51f, q51g, q59f1, q60f2, q61, q62, q63,
##     q69f1, q7, q70f2, q71, q7_oe1, q7_oe2, q7_oe3, q7vb, q81, q82,
##     q83, q84, q85, q90, q91, q92, qc1, qem1, qem2, qem3, ql1,
##     ql1a, qs1, race3m1, race3m2, race3m3, race3m4, racecmb,
##     racethn, refusal, reg, relig, sample, scregion, sex, sstate,
##     state, susr, treatment, usr, weight
moda<-function(q63){
  frec.var<-table(q63)
  valor<-which(frec.var==max(frec.var))  # Elementos con el valor
  names(valor)
}
moda(q63)
## [1] "Favors the poor"
#492 votantes opinan que el partido Democrata favorece solo a los pobres, y con 382 favoreciendo a los ricos, y solo una monoria piensa que no hay favoritismo. Y 456 personas opinan que favorecen a la clase media. 

## Podemos obervar que los votantes opinan que el partido democrata, tiene menos sezgado al tipo de clase social al cual "favorece", ya que la diferencia entre cada clase no es tan abrupta como la del Partido Republicano.

#Convertimos a factor numerico, para que este sea util al graficar.
democlases <- as.numeric(data$q63)
repoclases <- as.numeric(data$q62)

#q90. If you were asked to use one of these commonly used names for the social classes, which would you say you belong in? The upper class, upper-middle class, middle class, lower-middle class, or lower class?
count(data, "q90")    #contamos la frecuencia de cada clase.
##                         q90 freq
## 1              Upper class    35
## 2        Upper-middle class  259
## 3              Middle class  668
## 4        Lower-middle class  392
## 5               Lower class  126
## 6 Don't know/Refused (VOL.)   20
#1              Upper class  
#2        Upper-middle class  
#3              Middle class  
#4        Lower-middle class  
#5               Lower class  
#6 Don't know/Refused (VOL.)   

numericoq90 <- as.numeric(data$q90)
# En primer lugar con un 44.5333 % las personas se consideran en la clase media. Un 26.13333 % pertenece a clase Media Baja, el 17.26667% pertenece a Clase Media Alta. 
#Por ende concluir, que como la mayoria de votantes pertence a la clase media media alta, prefiere asi votar por el partido que mas le favorezca, y este es el Democrata.

sul <- c( 668 , 392 , 35)
ll <- c("MEDIA", "             MEDIABAJA", "                                                                        ALTA")
ppp <- round(sul/sum(sul)*100)
ll <- paste(ll, ppp)
ll <- paste(ll, "%", sep = " ")
lppp <- pie3D(radius = 17, sul, labels = ll, labelcex = 0.8, explode = 0.9, main = "Cantidad De Ciudadanos por Clase Social", col = c("skyblue", "pink", "orange"))

pnorm(668, mean = 3.25, sd = 0.9599206)
## [1] 1
#n <-  scale_fill_manual(values = c("skyblue", "royalblue", "blue", "navy", "red"), limits = c("1", "2", "3", "4", "5"), breaks =c("Republicano", "Democrata", "Ambos por Igual", "Ninguno", "No lo saben"), name = "fuel", labels = c("Republicano", "Democrata", "Ambos por Igual", "Ninguno", "No lo saben"))

#Graficamos la pregunta 44(a)
#c <- ggplot(data, aes(factor(Partya))) 

#QUIERO TRATAR DE PONER LEYENDAS PARA ESPECIFICAR QUE SIG CADA NUMERO EN CADA BARRA. 

correcto <- a + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Trabajo del Partido Lideando con la Economia") + xlab("Partidos") + ylab("Frecuencia") + theme(legend.position = "bottom") + guides(colour = guide_legend("A", "b","c","d","e"), size = guide_legend("a", "b","c","d", "e"), shape = guide_legend("1","2", "3", "4", "5", "6")) + scale_fill_discrete(name = "Categorias", labels = c("R", "D", "I", "N", "Z"))

#adios <- c + geom_bar(fill = "cyan3", colour = "cyan4") + ggtitle("Trabajo del Partido Lideando con la Economia") + xlab("Partidos") + ylab("Frecuencia") + theme(legend.position = "bottom") + guides(colour = guide_legend(label = TRUE, label.position = )

#guides(colour = guide_legend("title"), size = guide_legend("title"), shape = guide_legend("title"))
#"cyan3", colour = "cyan4"
#Para las clases sociales
boxplot(as.numeric(data$q62), range = 1.9, main = "Republican favors Rich/Middle/Poor class")

boxplot(as.numeric(data$q63), range = 1.5, width = NULL, varwidth = FALSE, notch = FALSE, outline = TRUE, main = "Democratic favors Rich/Middle/Poor class")

#Ciudadanos inclinados al partido.
boxplot(as.numeric(data$party),range = 1.5, width = NULL, varwidth = FALSE, notch = FALSE, outline = TRUE, main = "Pertenencia del Ciudadano a cada Partido")

boxplot(as.numeric(partylnna), range = 1.5, width = NULL, varwidth = FALSE, notch = FALSE, outline = TRUE, main = "De que Partido se Consideran")

boxplot(as.numeric(data2$q22d), range = 1.5, width = NULL, varwidth = FALSE, notch = FALSE, outline = TRUE, main = "Opinion en Calidad de D.Trump ")

boxplot(as.numeric(data2$q22d), width = NULL, varwidth = FALSE, notch = FALSE, outline = TRUE, main = " Opinion en Calidad de H. Clinton ",range = 1.5)

#DESVIACION STANDARD de El Partido que mejor lidera con la Economia
sd(Partya)
## [1] 1.172998
#DESVIACION STANDARD de El Partido que mejor lidera con la Inmigracion 
sd(Partyb)
## [1] 1.188055
#DESVIACION STANDARD de El Partido que mejor lidera con el Terrorismo
sd(Partyc)
## [1] 1.165817
#DESVIACION ESTANDAR, de el favoritismo a el tipo de clase social segun el partido republicano
sd(repoclases)
## [1] 1.065768
#DESVIACION ESTANDAR, de el favoritismo a el tipo de clase social segun el partido democrata
sd(democlases)
## [1] 1.097428
#Plot de lo que los ciudadnos opinan a que clase social El partido Republicano favorece. 
plot(repoclases, main="Los Republicanos favorecen a:", xlab="Cantidad de Ciudadanos", ylab= "Categorias", col = "skyblue")

#Plot de lo que los ciudadnos opinan a que clase social El partido Republicano favorece. 
plot(repoclases, main="Los Democratas favorecen a:", xlab="Cantidad de Ciudadanos", ylab= "Categorias", col = "dark red")

promedioclasealta <- (1500)/85
promedioclasemedia <- (427+456)

stem(as.numeric(data$q62))
## 
##   The decimal point is 1 digit(s) to the left of the |
## 
##   10 | 00000000000000000000000000000000000000000000000000000000000000000000+818
##   12 | 
##   14 | 
##   16 | 
##   18 | 
##   20 | 00000000000000000000000000000000000000000000000000000000000000000000+347
##   22 | 
##   24 | 
##   26 | 
##   28 | 
##   30 | 000000000000000000000000000
##   32 | 
##   34 | 
##   36 | 
##   38 | 
##   40 | 00000000000000000000000000000000000000000000000000000000000000000000
##   42 | 
##   44 | 
##   46 | 
##   48 | 
##   50 | 00000000000000000000000000000000000000000000000000000000000000000000
#PODEMOS ver la distribucion de la poblacion, y si esta a la deracha o izquierda.