if(!grepl("cz|utf", Sys.getlocale(), ignore.case = TRUE)) {
  Sys.setlocale(locale= 'English_United States.1250')
}
library(rlang)
library(lubridate)
library(tidyverse)
library(formr)
library(here)
library(RCzechia)
library(sf)
library(cowplot)
library(showtext)

library(vegan)

save_format <- ".svg"

theme_set(theme_cowplot())
dark_blue_color <- "#0040ae"
darkest_fill <- "#668cce"
midd_fill <- "#b2c5e6"
# theme_update(text = element_text(family = "Roboto", color = "white"), 
#              plot.background = element_rect(fill = dark_blue_color), 
#              line = element_line(color = "white"), 
#              rect = element_rect(color = "white"), 
#              axis.text = element_text(color = "white", face = "bold"), 
#              axis.title = element_text(color = "white"),
#              axis.line = element_line(color = "white"), axis.ticks = element_line(color = "white"),
#              strip.background = element_rect(color = "white", fill = darkest_fill))


#sysfonts::font_add_google("Roboto")
#sysfonts::font_add(family = "Skaut Bold", #paste0(Sys.getenv("APPDATA"),"/../Local/Microsoft/Windows/Fonts/skaut-bold-webfont.otf"))
#showtext_auto()

source(here::here("R","tools_dotaznik.R"), encoding = "UTF-8")
cela_data_raw <- nacti_dotaznik()
cela_data <- cela_data_raw %>% vyfiltruj_pouzitelne() %>% preprocess_dat(verbose = FALSE) %>% rozsir_vsechna_mc()

Rozdeleni roli

role_fa <- cela_data %>% select(starts_with("role_skauting_")) 

Pocet faktoru

Nejprve prozkoumame pocet faktoru

psych::fa.parallel(role_fa)
psych::vss(role_fa)

Vypada to neco mezi 4-6 faktory

4 faktoru

nfac <- 4 

role_fa_res <- psych::fa(role_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "role_skauting_") %>% 
  knitr::kable(digits = 2)

#cela_data2 <- vytvor_promenne_dle_fa(cela_data,role_fa,role_fa_res, var_name = "roleFA")

#cela_data2$skupina_role <- (cela_data2 %>% select(starts_with("roleFA")) %>% kmeans(centers = 4))$cluster

#cela_data2 %>% 
#  select(skupina_role,starts_with("roleFA")) %>% 
#  group_by(skupina_role) %>% 
#  summarize_each(mean) %>% 
#  pivot_longer(cols = starts_with("roleFA"),names_to = "role",values_to = "perc") %>% 
#  ggplot(aes(x = role, y=perc)) + geom_col() +
#  facet_grid(skupina_role~.)
#  theme(aspect.ratio = 1)

5 faktoru

nfac <- 5 

role_fa_res <- psych::fa(role_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "role_skauting_") %>% 
  knitr::kable(digits = 2)

6 faktoru

nfac <- 6 

role_fa_res <- psych::fa(role_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "role_skauting_") %>% 
  knitr::kable(digits = 2)

Osobne se mi libi rozdeleni na 6 roli

Fungovani oddilu

fung_odd_fa <- cela_data %>% select(starts_with("fungovani_skautskeho_oddilu_")) 

Pocet faktoru

Nejprve prozkoumame pocet faktoru

psych::fa.parallel(fung_odd_fa)
psych::vss(fung_odd_fa)

Vypada to neco mezi 2-4 faktory

2 faktory

nfac <- 2

role_fa_res <- psych::fa(fung_odd_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "fungovani_skautskeho_oddilu_") %>% 
  knitr::kable(digits = 2)

3 faktory

nfac <- 3

role_fa_res <- psych::fa(fung_odd_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "fungovani_skautskeho_oddilu_") %>% 
  knitr::kable(digits = 2)

4 faktory

nfac <- 4

role_fa_res <- psych::fa(fung_odd_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "fungovani_skautskeho_oddilu_") %>% 
  knitr::kable(digits = 2)

5 faktory

nfac <- 5

role_fa_res <- psych::fa(fung_odd_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(role_fa_res, nfac = nfac, str_to_remove = "fungovani_skautskeho_oddilu_") %>% 
  knitr::kable(digits = 2)

Nic moc

Vychovne nastroje

vychovne_nastroje_fa <- cela_data %>% select(starts_with("vychovne_nastroje_")) 

Pocet faktoru

Nejprve prozkoumame pocet faktoru

psych::fa.parallel(vychovne_nastroje_fa)
psych::vss(vychovne_nastroje_fa)

Tedy 3-6 faktoru

3 faktory

nfac <- 3

vych_nastroje_fa_res <- psych::fa(vychovne_nastroje_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(vych_nastroje_fa_res, nfac = nfac, str_to_remove = "vychovne_nastroje_") %>% 
  knitr::kable(digits = 2)

4 faktory

nfac <- 4

vych_nastroje_fa_res <- psych::fa(vychovne_nastroje_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(vych_nastroje_fa_res, nfac = nfac, str_to_remove = "vychovne_nastroje_") %>% 
  knitr::kable(digits = 2)

5 faktory

nfac <- 5

vych_nastroje_fa_res <- psych::fa(vychovne_nastroje_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(vych_nastroje_fa_res, nfac = nfac, str_to_remove = "vychovne_nastroje_") %>% 
  knitr::kable(digits = 2)

6 faktory

nfac <- 6

vych_nastroje_fa_res <- psych::fa(vychovne_nastroje_fa, nfactors = nfac, rotate = "varimax")

zobraz_fa(vych_nastroje_fa_res, nfac = nfac, str_to_remove = "vychovne_nastroje_") %>% 
  knitr::kable(digits = 2)


martinmodrak/revize-rs documentation built on March 1, 2021, 9:10 p.m.