Úvodná informácia o súbore

rm(list=ls())
library(mice)
## 
## Attaching package: 'mice'
## The following object is masked from 'package:stats':
## 
##     filter
## The following objects are masked from 'package:base':
## 
##     cbind, rbind
library(janitor)
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     fisher.test, chisq.test
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(Rcpp)
library(Amelia)
## ## 
## ## Amelia II: Multiple Imputation
## ## (Version 1.8.3, built: 2024-11-07)
## ## Copyright (C) 2005-2026 James Honaker, Gary King and Matthew Blackwell
## ## Refer to http://gking.harvard.edu/amelia/ for more information
## ##
library(ggplot2)
# velkost suboru
print(file.info("C:/Users/marti/OneDrive/Dokumenty/škola/udaje/Questionary.csv")$size)
## [1] 19660
rm(list=ls())
udaje <- read.csv2("C:/Users/marti/OneDrive/Dokumenty/škola/udaje/Questionary.csv", sep=";") # import dat
head(udaje)
##   My_culture_should_be_the_role_model_for_other_cultures
## 1                                                      2
## 2                                                      3
## 3                                                      2
## 4                                                      2
## 5                                                      3
## 6                                                      2
##   Other_cultures_should_try_to_be_more_like_my_culture
## 1                                                   NA
## 2                                                    3
## 3                                                    1
## 4                                                    2
## 5                                                    3
## 6                                                    2
##   I_m_not_interested_in_the_values_and_customs_of_other_cultures
## 1                                                              1
## 2                                                              1
## 3                                                              2
## 4                                                              1
## 5                                                              1
## 6                                                              2
##   Most_people_from_other_cultures_just_do_not_know_what_is_good_for_them
## 1                                                                      1
## 2                                                                      3
## 3                                                                      2
## 4                                                                      4
## 5                                                                      1
## 6                                                                      4
##   People_from_my_culture_act_strange_and_unusual_when_they_go_into_other_cultures
## 1                                                                               3
## 2                                                                               1
## 3                                                                               3
## 4                                                                               4
## 5                                                                               2
## 6                                                                               2
##   I_have_little_respect_for_the_values_and_customs_of_other_cultures
## 1                                                                  1
## 2                                                                  3
## 3                                                                  1
## 4                                                                  1
## 5                                                                  1
## 6                                                                  4
##   Most_people_would_be_happier_if_they_lived_like_people_in_my_culture
## 1                                                                    1
## 2                                                                    4
## 3                                                                    2
## 4                                                                    2
## 5                                                                    3
## 6                                                                    5
##   People_in_my_culture_have_just_about_the_best_lifestyles_of_anywhere
## 1                                                                    2
## 2                                                                    4
## 3                                                                    3
## 4                                                                    2
## 5                                                                    3
## 6                                                                    2
##   Generally__I_am_comfortable_interacting_with_a_group_of_people_from_different_cultures
## 1                                                                                      3
## 2                                                                                      5
## 3                                                                                      4
## 4                                                                                      4
## 5                                                                                      3
## 6                                                                                      4
##   I_like_to_get_involved_in_group_discussion_with_others_who_are_from_different_cultures
## 1                                                                                      3
## 2                                                                                      4
## 3                                                                                      4
## 4                                                                                      4
## 5                                                                                      4
## 6                                                                                      4
##   I_am_calm_and_relaxed_with_interacting_with_a_group_of_people_who_are_from_different_cultures
## 1                                                                                             3
## 2                                                                                             4
## 3                                                                                             4
## 4                                                                                             4
## 5                                                                                             4
## 6                                                                                             3
##   I_have_no_fear_of_speaking_up_._in_a_conversation_with_a_person_from_a_different_culture
## 1                                                                                        3
## 2                                                                                        4
## 3                                                                                        4
## 4                                                                                        3
## 5                                                                                        4
## 6                                                                                        4
##   While_conversing_with_a_person_from_a_different_culture_I_feel_very_relaxed
## 1                                                                           2
## 2                                                                           4
## 3                                                                           4
## 4                                                                           3
## 5                                                                           4
## 6                                                                           3
##   I_face_the_prospect_of_interacting_with_people_from_different_cultures_with_confidence
## 1                                                                                      2
## 2                                                                                      5
## 3                                                                                      4
## 4                                                                                      3
## 5                                                                                      4
## 6                                                                                      3
##   I_enjoy_interacting_with_people_from_different_cultures
## 1                                                       3
## 2                                                       5
## 3                                                       4
## 4                                                       4
## 5                                                       4
## 6                                                       4
##   In_a_sense__I_am_emotionally_attached_to_my_country_and_emotionally_affected_by_its_actions
## 1                                                                                           3
## 2                                                                                           4
## 3                                                                                           4
## 4                                                                                           5
## 5                                                                                           3
## 6                                                                                           4
##   Although_at_times_I_may_not_4_with_the_government__my_commitment_to_my_country_always_remains_strong
## 1                                                                                                    3
## 2                                                                                                    4
## 3                                                                                                    4
## 4                                                                                                    5
## 5                                                                                                    4
## 6                                                                                                    4
##   When_I_see_my_country_s_flag_flying_I_feel_great
## 1                                                3
## 2                                                5
## 3                                                4
## 4                                                5
## 5                                                4
## 6                                                4
##   The_fact_that_I_am_a_citizen_of_my_country__is_an_important_part_of_my_identity
## 1                                                                               3
## 2                                                                               5
## 3                                                                               4
## 4                                                                               5
## 5                                                                               4
## 6                                                                               3
##   I_would_support_my_country_right_or_wrong
## 1                                         2
## 2                                         5
## 3                                         3
## 4                                         3
## 5                                         2
## 6                                         4
##   I_believe_that_my_country_s_policies_are_almost_always_the_morally_correct_ones
## 1                                                                               1
## 2                                                                               4
## 3                                                                               3
## 4                                                                               2
## 5                                                                               2
## 6                                                                               1
##   People_should_work_hard_to_move_my_country_in_a_positive_direction
## 1                                                                  3
## 2                                                                  4
## 3                                                                  3
## 4                                                                  4
## 5                                                                  4
## 6                                                                  4
##   Interacting_with_local_employees_makes_me_uneasy
## 1                                                1
## 2                                                3
## 3                                                2
## 4                                                3
## 5                                                2
## 6                                                2
##   I_doubt_that_local_employees_will_put_their_interest_ahead_of_that_of_expatriates
## 1                                                                                 2
## 2                                                                                 3
## 3                                                                                 1
## 4                                                                                 3
## 5                                                                                 3
## 6                                                                                 4
##   I_am_afraid_that_I_will_lose_my_own_cultural_orientations_with_more_time_I_spent_in_foreign_assignment
## 1                                                                                                      1
## 2                                                                                                      2
## 3                                                                                                      2
## 4                                                                                                      2
## 5                                                                                                      2
## 6                                                                                                      2
##   My_fellow_colleagues_who_are_not_from_my_country_have_less_ability_and_intelligence_than_the_average
## 1                                                                                                    1
## 2                                                                                                    1
## 3                                                                                                    2
## 4                                                                                                    2
## 5                                                                                                    2
## 6                                                                                                    2
##   There_is_a_great_deal_of_bad_behaviour_among_my_fellow_colleagues_who_are_not_from_my_country
## 1                                                                                             1
## 2                                                                                             3
## 3                                                                                             2
## 4                                                                                             3
## 5                                                                                             2
## 6                                                                                             2
##   My_fellow_colleagues_who_are_not_from_my_country__are_less_virtuous_and_moral_than_most_other_citizens_in_my_country
## 1                                                                                                                    1
## 2                                                                                                                    3
## 3                                                                                                                    2
## 4                                                                                                                    2
## 5                                                                                                                    4
## 6                                                                                                                    3
##   I_keep_my_fellow_colleagues_who_are_not_from_my_country_out_of_my_everyday_life_if_I_can
## 1                                                                                        1
## 2                                                                                        2
## 3                                                                                        2
## 4                                                                                        2
## 5                                                                                        3
## 6                                                                                        2
##   Gender          Age Marital.Status Nationality                   Education
## 1      0      30 - 40        Married      Indian                    Master's
## 2      1      30 - 40    Not Married  Srilankan  Less than Bachelor's Degree
## 3      0 More than 40        Married      Indian           Bachelor's Degree
## 4      0      30 - 40        Married      Indian           Bachelor's Degree
## 5      0      30 - 40        Unknown   Filipino            Bachelor's Degree
## 6      1      30 - 40        Married  Sri lankan           Bachelor's Degree
##   Employment.Status             Position.level      Country.of.Employment
## 1         Full time     Professional/Technical United Arab Emirates (UAE)
## 2         Full time    Middle/Lower Management United Arab Emirates (UAE)
## 3         Full time Operational Level Employee United Arab Emirates (UAE)
## 4         Full time Operational Level Employee United Arab Emirates (UAE)
## 5         Full time    Middle/Lower Management United Arab Emirates (UAE)
## 6         Full time     Professional/Technical United Arab Emirates (UAE)
##   Length.of.Stay.in.the.Country.of.Employment
## 1                           More than 4 Years
## 2                           More than 4 Years
## 3                           More than 4 Years
## 4                           More than 4 Years
## 5                           More than 4 Years
## 6                           More than 4 Years
##                                                                        Category.of.Expatriation
## 1 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 2 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 3 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 4 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 5 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 6 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)

Názvy premenných

Funkcia clean_names() z balíka janitor dokáže automaticky previesť názvy stĺpcov na malé písmená, odstrániť medzery a nealfanumerické znaky a zabezpečiť, aby bol každý názov stĺpca jedinečný.

library(janitor)


# Clean up the column names - skratenie a uprava nazvov
udaje <- udaje %>%
  clean_names()
head(udaje)
##   my_culture_should_be_the_role_model_for_other_cultures
## 1                                                      2
## 2                                                      3
## 3                                                      2
## 4                                                      2
## 5                                                      3
## 6                                                      2
##   other_cultures_should_try_to_be_more_like_my_culture
## 1                                                   NA
## 2                                                    3
## 3                                                    1
## 4                                                    2
## 5                                                    3
## 6                                                    2
##   i_m_not_interested_in_the_values_and_customs_of_other_cultures
## 1                                                              1
## 2                                                              1
## 3                                                              2
## 4                                                              1
## 5                                                              1
## 6                                                              2
##   most_people_from_other_cultures_just_do_not_know_what_is_good_for_them
## 1                                                                      1
## 2                                                                      3
## 3                                                                      2
## 4                                                                      4
## 5                                                                      1
## 6                                                                      4
##   people_from_my_culture_act_strange_and_unusual_when_they_go_into_other_cultures
## 1                                                                               3
## 2                                                                               1
## 3                                                                               3
## 4                                                                               4
## 5                                                                               2
## 6                                                                               2
##   i_have_little_respect_for_the_values_and_customs_of_other_cultures
## 1                                                                  1
## 2                                                                  3
## 3                                                                  1
## 4                                                                  1
## 5                                                                  1
## 6                                                                  4
##   most_people_would_be_happier_if_they_lived_like_people_in_my_culture
## 1                                                                    1
## 2                                                                    4
## 3                                                                    2
## 4                                                                    2
## 5                                                                    3
## 6                                                                    5
##   people_in_my_culture_have_just_about_the_best_lifestyles_of_anywhere
## 1                                                                    2
## 2                                                                    4
## 3                                                                    3
## 4                                                                    2
## 5                                                                    3
## 6                                                                    2
##   generally_i_am_comfortable_interacting_with_a_group_of_people_from_different_cultures
## 1                                                                                     3
## 2                                                                                     5
## 3                                                                                     4
## 4                                                                                     4
## 5                                                                                     3
## 6                                                                                     4
##   i_like_to_get_involved_in_group_discussion_with_others_who_are_from_different_cultures
## 1                                                                                      3
## 2                                                                                      4
## 3                                                                                      4
## 4                                                                                      4
## 5                                                                                      4
## 6                                                                                      4
##   i_am_calm_and_relaxed_with_interacting_with_a_group_of_people_who_are_from_different_cultures
## 1                                                                                             3
## 2                                                                                             4
## 3                                                                                             4
## 4                                                                                             4
## 5                                                                                             4
## 6                                                                                             3
##   i_have_no_fear_of_speaking_up_in_a_conversation_with_a_person_from_a_different_culture
## 1                                                                                      3
## 2                                                                                      4
## 3                                                                                      4
## 4                                                                                      3
## 5                                                                                      4
## 6                                                                                      4
##   while_conversing_with_a_person_from_a_different_culture_i_feel_very_relaxed
## 1                                                                           2
## 2                                                                           4
## 3                                                                           4
## 4                                                                           3
## 5                                                                           4
## 6                                                                           3
##   i_face_the_prospect_of_interacting_with_people_from_different_cultures_with_confidence
## 1                                                                                      2
## 2                                                                                      5
## 3                                                                                      4
## 4                                                                                      3
## 5                                                                                      4
## 6                                                                                      3
##   i_enjoy_interacting_with_people_from_different_cultures
## 1                                                       3
## 2                                                       5
## 3                                                       4
## 4                                                       4
## 5                                                       4
## 6                                                       4
##   in_a_sense_i_am_emotionally_attached_to_my_country_and_emotionally_affected_by_its_actions
## 1                                                                                          3
## 2                                                                                          4
## 3                                                                                          4
## 4                                                                                          5
## 5                                                                                          3
## 6                                                                                          4
##   although_at_times_i_may_not_4_with_the_government_my_commitment_to_my_country_always_remains_strong
## 1                                                                                                   3
## 2                                                                                                   4
## 3                                                                                                   4
## 4                                                                                                   5
## 5                                                                                                   4
## 6                                                                                                   4
##   when_i_see_my_country_s_flag_flying_i_feel_great
## 1                                                3
## 2                                                5
## 3                                                4
## 4                                                5
## 5                                                4
## 6                                                4
##   the_fact_that_i_am_a_citizen_of_my_country_is_an_important_part_of_my_identity
## 1                                                                              3
## 2                                                                              5
## 3                                                                              4
## 4                                                                              5
## 5                                                                              4
## 6                                                                              3
##   i_would_support_my_country_right_or_wrong
## 1                                         2
## 2                                         5
## 3                                         3
## 4                                         3
## 5                                         2
## 6                                         4
##   i_believe_that_my_country_s_policies_are_almost_always_the_morally_correct_ones
## 1                                                                               1
## 2                                                                               4
## 3                                                                               3
## 4                                                                               2
## 5                                                                               2
## 6                                                                               1
##   people_should_work_hard_to_move_my_country_in_a_positive_direction
## 1                                                                  3
## 2                                                                  4
## 3                                                                  3
## 4                                                                  4
## 5                                                                  4
## 6                                                                  4
##   interacting_with_local_employees_makes_me_uneasy
## 1                                                1
## 2                                                3
## 3                                                2
## 4                                                3
## 5                                                2
## 6                                                2
##   i_doubt_that_local_employees_will_put_their_interest_ahead_of_that_of_expatriates
## 1                                                                                 2
## 2                                                                                 3
## 3                                                                                 1
## 4                                                                                 3
## 5                                                                                 3
## 6                                                                                 4
##   i_am_afraid_that_i_will_lose_my_own_cultural_orientations_with_more_time_i_spent_in_foreign_assignment
## 1                                                                                                      1
## 2                                                                                                      2
## 3                                                                                                      2
## 4                                                                                                      2
## 5                                                                                                      2
## 6                                                                                                      2
##   my_fellow_colleagues_who_are_not_from_my_country_have_less_ability_and_intelligence_than_the_average
## 1                                                                                                    1
## 2                                                                                                    1
## 3                                                                                                    2
## 4                                                                                                    2
## 5                                                                                                    2
## 6                                                                                                    2
##   there_is_a_great_deal_of_bad_behaviour_among_my_fellow_colleagues_who_are_not_from_my_country
## 1                                                                                             1
## 2                                                                                             3
## 3                                                                                             2
## 4                                                                                             3
## 5                                                                                             2
## 6                                                                                             2
##   my_fellow_colleagues_who_are_not_from_my_country_are_less_virtuous_and_moral_than_most_other_citizens_in_my_country
## 1                                                                                                                   1
## 2                                                                                                                   3
## 3                                                                                                                   2
## 4                                                                                                                   2
## 5                                                                                                                   4
## 6                                                                                                                   3
##   i_keep_my_fellow_colleagues_who_are_not_from_my_country_out_of_my_everyday_life_if_i_can
## 1                                                                                        1
## 2                                                                                        2
## 3                                                                                        2
## 4                                                                                        2
## 5                                                                                        3
## 6                                                                                        2
##   gender          age marital_status nationality                   education
## 1      0      30 - 40        Married      Indian                    Master's
## 2      1      30 - 40    Not Married  Srilankan  Less than Bachelor's Degree
## 3      0 More than 40        Married      Indian           Bachelor's Degree
## 4      0      30 - 40        Married      Indian           Bachelor's Degree
## 5      0      30 - 40        Unknown   Filipino            Bachelor's Degree
## 6      1      30 - 40        Married  Sri lankan           Bachelor's Degree
##   employment_status             position_level      country_of_employment
## 1         Full time     Professional/Technical United Arab Emirates (UAE)
## 2         Full time    Middle/Lower Management United Arab Emirates (UAE)
## 3         Full time Operational Level Employee United Arab Emirates (UAE)
## 4         Full time Operational Level Employee United Arab Emirates (UAE)
## 5         Full time    Middle/Lower Management United Arab Emirates (UAE)
## 6         Full time     Professional/Technical United Arab Emirates (UAE)
##   length_of_stay_in_the_country_of_employment
## 1                           More than 4 Years
## 2                           More than 4 Years
## 3                           More than 4 Years
## 4                           More than 4 Years
## 5                           More than 4 Years
## 6                           More than 4 Years
##                                                                        category_of_expatriation
## 1 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 2 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 3 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 4 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 5 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 6 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)

Skrátene názvov premenných

library(stringr)

# Load the data
#udaje <- read.csv("your_file.csv")

# Shorten the column names
data_names <- names(udaje)
short_names <- str_sub(data_names, 1, 10) # shorten to first 10 characters
short_names <- make.unique(short_names) # ensure that each name is unique

# Rename the columns
names(udaje) <- short_names

head(udaje)
##   my_culture other_cult i_m_not_in most_peopl people_fro i_have_lit
## 1          2         NA          1          1          3          1
## 2          3          3          1          3          1          3
## 3          2          1          2          2          3          1
## 4          2          2          1          4          4          1
## 5          3          3          1          1          2          1
## 6          2          2          2          4          2          4
##   most_peopl.1 people_in_ generally_ i_like_to_ i_am_calm_ i_have_no_
## 1            1          2          3          3          3          3
## 2            4          4          5          4          4          4
## 3            2          3          4          4          4          4
## 4            2          2          4          4          4          3
## 5            3          3          3          4          4          4
## 6            5          2          4          4          3          4
##   while_conv i_face_the i_enjoy_in in_a_sense although_a when_i_see the_fact_t
## 1          2          2          3          3          3          3          3
## 2          4          5          5          4          4          5          5
## 3          4          4          4          4          4          4          4
## 4          3          3          4          5          5          5          5
## 5          4          4          4          3          4          4          4
## 6          3          3          4          4          4          4          3
##   i_would_su i_believe_ people_sho interactin i_doubt_th i_am_afrai my_fellow_
## 1          2          1          3          1          2          1          1
## 2          5          4          4          3          3          2          1
## 3          3          3          3          2          1          2          2
## 4          3          2          4          3          3          2          2
## 5          2          2          4          2          3          2          2
## 6          4          1          4          2          4          2          2
##   there_is_a my_fellow_.1 i_keep_my_ gender          age  marital_st
## 1          1            1          1      0      30 - 40     Married
## 2          3            3          2      1      30 - 40 Not Married
## 3          2            2          2      0 More than 40     Married
## 4          3            2          2      0      30 - 40     Married
## 5          2            4          3      0      30 - 40     Unknown
## 6          2            3          2      1      30 - 40     Married
##    nationalit                   education employment                 position_l
## 1      Indian                    Master's  Full time     Professional/Technical
## 2  Srilankan  Less than Bachelor's Degree  Full time    Middle/Lower Management
## 3      Indian           Bachelor's Degree  Full time Operational Level Employee
## 4      Indian           Bachelor's Degree  Full time Operational Level Employee
## 5   Filipino            Bachelor's Degree  Full time    Middle/Lower Management
## 6  Sri lankan           Bachelor's Degree  Full time     Professional/Technical
##                   country_of        length_of_
## 1 United Arab Emirates (UAE) More than 4 Years
## 2 United Arab Emirates (UAE) More than 4 Years
## 3 United Arab Emirates (UAE) More than 4 Years
## 4 United Arab Emirates (UAE) More than 4 Years
## 5 United Arab Emirates (UAE) More than 4 Years
## 6 United Arab Emirates (UAE) More than 4 Years
##                                                                                      category_o
## 1 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 2 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 3 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 4 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 5 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
## 6 Self Initiated Expatriate (found the job by yourself before or after arriving at the country)
# cleaning names of varibles
colnames(udaje)
##  [1] "my_culture"   "other_cult"   "i_m_not_in"   "most_peopl"   "people_fro"  
##  [6] "i_have_lit"   "most_peopl.1" "people_in_"   "generally_"   "i_like_to_"  
## [11] "i_am_calm_"   "i_have_no_"   "while_conv"   "i_face_the"   "i_enjoy_in"  
## [16] "in_a_sense"   "although_a"   "when_i_see"   "the_fact_t"   "i_would_su"  
## [21] "i_believe_"   "people_sho"   "interactin"   "i_doubt_th"   "i_am_afrai"  
## [26] "my_fellow_"   "there_is_a"   "my_fellow_.1" "i_keep_my_"   "gender"      
## [31] "age"          "marital_st"   "nationalit"   "education"    "employment"  
## [36] "position_l"   "country_of"   "length_of_"   "category_o"

Čistenie obsahu databázy

Chýbajúce údaje a základné imputácie

library(Amelia)

# Load your data
#data <- read.csv("your_file.csv")

# Create a missing map
missmap(udaje, col=c("yellow", "black"), legend=TRUE)

Čistenie prázdnych riadkov a stĺpcov

# cistenie uplne prazdnych stlpcov alebo riadkov
udaje <- udaje %>% remove_empty(whic=c("rows"))
udaje.tmp <<- udaje %>% remove_empty(whic=c("cols"))
attach(udaje)   # grafical information about the relation among the variables
pairs(udaje[,c(1,2,3,4,5,6,7,8,9,10)])

Missing data and basic imputations

library(Amelia)

# Load your data
#data <- read.csv("your_file.csv")

# Create a missing map
missmap(udaje, col=c("yellow", "black"), legend=TRUE)

# nahradenie chybajucich udajov ich strednymi hodnotami (najjednoduchsie ale nie efektivne riesenie)
udaje_imputed <- udaje

for(i in 1:ncol(udaje_imputed)){
  udaje_imputed[is.na(udaje_imputed[,i]), i] <- mean(udaje_imputed[,i], na.rm = TRUE)
}
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
## Warning in mean.default(udaje_imputed[, i], na.rm = TRUE): argument is not
## numeric or logical: returning NA
udaje <- udaje_imputed

#  nahradenie cisel v textovom formate samotnymi cislami (ak nie je databaza 'dokonala')

udaje[] <- lapply(udaje, function(x)
  if(is.factor(x)) as.numeric(as.character(x)) else x)