## Registered S3 methods overwritten by 'tibble':
## method from
## format.tbl pillar
## print.tbl pillar
## -- Attaching packages ---- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.7
## v tidyr 1.1.1 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## Warning: package 'dplyr' was built under R version 4.0.5
## -- Conflicts ------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## Warning: package 'VIM' was built under R version 4.0.5
## Loading required package: colorspace
## Loading required package: grid
## VIM is ready to use.
## Suggestions and bug-reports can be submitted at: https://github.com/statistikat/VIM/issues
##
## Attaching package: 'VIM'
## The following object is masked from 'package:datasets':
##
## sleep
otros <- function(Data, filt1, filt2, titulo) {
colnames(Data) <- c("var1", "var2")
Data %>%
select(var1, var2) %>%
mutate(var2 = str_to_title(var2),
var2 = ifelse(var2 == "", NA, var2)) %>%
filter(var1 == filt1 | var1 == filt2) %>%
filter(!is.na(var2)) %>%
count(var2, sort = TRUE) %>%
mutate(porcentaje = paste0(sprintf("%4.1f", n / sum(n) * 100), "%")) %>%
datatable(colnames = c("Respuesta", "Frecuencia", "Porcentaje"), caption = titulo, class = "cell-border stripe", editable = TRUE, extensions = "Buttons", options = list(dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print")))
}Docentes <- Docentes %>%
mutate(q0002_0001 = str_to_title(q0002_0001),
q0002_0001 = str_replace(q0002_0001, "Limq", "Lima"),
q0002_0001 = str_replace(q0002_0001, "Lina", "Lima"),
q0002_0001 = str_replace(q0002_0001, "Liam", "Lima"),
q0002_0001 = str_replace(q0002_0001, "Ics", "Ica"),
q0002_0001 = str_replace(q0002_0001, "Lim ", "Lima"),
q0002_0001 = str_replace(q0002_0001, "Pisco Ica", "Ica"),
q0002_0001 = ifelse(q0002_0001 == "", NA, q0002_0001),
q0002_0002 = str_to_title(q0002_0002),
q0002_0002 = str_replace(q0002_0002, "Chincha|", "Chincha"),
q0002_0002 = str_replace(q0002_0002, "Liam", "Lima"),
q0002_0003 = str_to_title(q0002_0003),
q0002_0003 = str_replace(q0002_0003, "Smp", "San Martín De Porres"),
q0002_0003 = str_replace(q0002_0003, "Villa Maria Del Triunfo", "Villa María Del Triunfo"),
q0002_0003 = str_replace(q0002_0003, "Chorrilos", "Chorrillos"),
q0002_0003 = str_replace(q0002_0003, "Ics", "Ica"),
q0002_0003 = str_replace(q0002_0003, "San Juan De Lurignacho", "San Juan De Lurigancho"),
q0002_0003 = str_replace(q0002_0003, "Lurín", "Lurin"),
q0002_0003 = str_replace(q0002_0003, "San Martin De Porres", "San Martín De Porres"))Docentes %>%
select(q0002_0001:q0002_0003) %>%
group_by(q0002_0001, q0002_0002, q0002_0003) %>%
count(q0002_0003, sort = TRUE) %>%
ungroup() %>%
mutate(porcentaje = paste0(sprintf("%4.1f", n / sum(n) * 100), "%")) %>%
datatable(colnames = c("Departamento", "Provincia", "Distrito", "Frecuencia", "porcentaje"), caption = "¿Dónde vive actualmente?", class = "cell-border stripe", editable = TRUE, extensions = "Buttons", options = list(dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print"))) Docentes %>%
select(q0036) %>%
mutate(q0036 = str_to_title(q0036),
q0036 = ifelse(q0036 == "", NA, q0036)) %>%
filter(!is.na(q0036)) %>%
count(q0036, sort = TRUE) %>%
mutate(porcentaje = paste0(sprintf("%4.1f", n / sum(n) * 100), "%")) %>%
datatable(colnames = c("Respuesta", "Frecuencia", "Porcentaje"), caption = "¿Cómo planifica sus visitas al museo con sus estudiantes?", class = "cell-border stripe", editable = TRUE, extensions = "Buttons", options = list(dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print"))) Docentes %>%
select(q0052) %>%
mutate(q0052 = str_to_title(q0052),
q0052 = ifelse(q0052 == "", NA, q0052)) %>%
filter(!is.na(q0052)) %>%
count(q0052, sort = TRUE) %>%
mutate(porcentaje = paste0(sprintf("%4.1f", n / sum(n) * 100), "%")) %>%
datatable(colnames = c("Respuesta", "Frecuencia", "Porcentaje"), caption = "¿A que museo pertenecía dicha publicidad?", class = "cell-border stripe", editable = TRUE, extensions = "Buttons", options = list(dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print"))) Docentes %>%
select(q0055) %>%
mutate(q0055 = str_to_title(q0055),
q0055 = ifelse(q0055 == "", NA, q0055)) %>%
filter(!is.na(q0055)) %>%
count(q0055, sort = TRUE) %>%
mutate(porcentaje = paste0(sprintf("%4.1f", n / sum(n) * 100), "%")) %>%
datatable(colnames = c("Respuesta", "Frecuencia", "Porcentaje"), caption = "¿Qué es un museo nacional para usted?", class = "cell-border stripe", editable = TRUE, extensions = "Buttons", options = list(dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print")))Docentes %>%
select(q0056_0001:q0056_0003) %>%
gather(key = "key", value = "value") %>%
mutate(value = ifelse(value == "", NA, value)) %>%
filter(!is.na(value)) %>%
mutate(value = str_to_title(value)) %>%
count(value, sort = TRUE) %>%
mutate(porcentaje = paste0(sprintf("%4.1f", n / sum(n) * 100), "%")) %>%
datatable(colnames = c("Respuesta", "Frecuencia", "Porcentaje"), caption = "Indique tres palabras que en su opinión definan el Museo Nacional del Perú", class = "cell-border stripe", editable = TRUE, extensions = "Buttons", options = list(dom = "Bfrtip", buttons = c("copy", "csv", "excel", "pdf", "print")))## Warning: attributes are not identical across measure variables;
## they will be dropped