This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(haven)
## Warning: package 'haven' was built under R version 4.5.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.3
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
lapop23 <- read_sav("D:/DocumentosUsuarioSalas/santa fe/lapop23.sav")
View(lapop23)
df <- lapop23 %>%
select(q2, vic1ext, aoj11) %>%
filter(
q2 >= 18 & q2 <= 87,
vic1ext >= 1 & vic1ext <= 2,
aoj11 >= 1 & aoj11 <= 4
)
glimpse(df)
## Rows: 1,492
## Columns: 3
## $ q2 <dbl+lbl> 24, 43, 60, 50, 58, 26, 30, 27, 48, 47, 45, 18, 82, 47, 73…
## $ vic1ext <dbl+lbl> 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 2…
## $ aoj11 <dbl+lbl> 4, 4, 2, 2, 1, 3, 1, 3, 3, 1, 2, 2, 4, 4, 2, 2, 4, 2, 3, 3…
library(dplyr)
lapop23 <- read_sav("D:/DocumentosUsuarioSalas/santa fe/lapop23.sav") |>
mutate(
percepcion_seguridad = factor(aoj11,
levels = c(1,2,3,4),
labels = c("muy seguro",
"algo seguro",
"algo inseguro",
"muy inseguro"
))
)
library(ggpattern)
## Warning: package 'ggpattern' was built under R version 4.5.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.3
library(hrbrthemes)
## Warning: package 'hrbrthemes' was built under R version 4.5.3
# 1. Crear la tabla de frecuencias absolutas
tabla_seguridad <- as.data.frame(table(df$aoj11))
colnames(tabla_seguridad) <- c("Seguridad", "Frecuencia")
# 2. Elaborar el gráfico de barras con texturas
ggplot(tabla_seguridad, aes(x=Seguridad, y=Frecuencia)) +
geom_col_pattern(
aes(pattern=Seguridad,
pattern_angle=Seguridad,
pattern_spacing=Seguridad
),
fill = 'white',
colour = 'black',
pattern_density = 0.5,
pattern_fill = 'black',
pattern_colour = 'darkgrey'
) +
theme_bw()
###The Latin American Public Opinion Project (LAPOP) at Vanderbilt University is a center for excellence in international survey research. LAPOP uses rigorous scientific approaches and innovative methods to carry out studies of public opinion and behavior.###
LAPOP’s largest survey research project is the AmericasBarometer, a regular study of public opinion in 34 countries in the Western Hemisphere, with stratified nationally representative samples drawn in each country, a common questionnaire core, and country-specific modules. LAPOP’s work on the AmericasBarometer includes questionnaire development, sample design, qualitative and iterative pre-testing, data auditing, and analysis and reporting. Alongside the use of electronic devices and specialized software for fieldwork, LAPOP employs a proprietary quality control program, which improves the tracking of response rates, prevents location errors in the sample, prevents fraud, and increases interview quality. ## Including Plots
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.