# import an excel file
mydata <- read_excel("C:/Users/Eneja/Desktop/anketa10.xlsx")

# delete first row in which the questions are written
mydata <- mydata[-1,]



# add an ID variable
mydata$ID <- 1:nrow(mydata)

mydata <- mydata[,c(93, 1:92)]

head(mydata)
## # A tibble: 6 × 93
##      ID Q1    Q2    Q3    Q4    Q5    Q6a   Q6b   Q6c   Q6d   Q7a_1 Q7b_1 Q7c_1 Q7d_1 Q7e_1 Q7f_1 Q8a   Q8b   Q8c   Q8d   Q9a  
##   <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1     1 7     2     -2    -2    -2    1     5     5     5         7    10    16    16    16    80 3     5     2     4     5    
## 2     2 6     2     -2    -2    -2    3     4     5     3         0    22    59     0    23    57 4     4     1     4     5    
## 3     3 5     2     -2    -2    -2    4     4     3     3         0    26    63    17     0   100 4     2     2     4     4    
## 4     4 7     1     3     4     2     5     4     3     2        82     0    85    63    85   100 5     4     1     4     5    
## 5     5 7     2     -2    -2    -2    4     2     4     5         0     0     0     0    25    50 5     1     1     1     5    
## 6     6 7     1     3     4     2     4     4     4     2         0     0    -1     0     0    70 4     4     1     2     5    
## # … with 72 more variables: Q9b <chr>, Q9c <chr>, Q9d <chr>, Q10a <chr>, Q10b <chr>, Q10c <chr>, Q10d <chr>, Q10e <chr>,
## #   Q10f <chr>, Q10g <chr>, Q10h <chr>, Q11 <chr>, Q11_9_text <chr>, Q12a <chr>, Q12b <chr>, Q12c <chr>, Q12d <chr>, Q12e <chr>,
## #   Q12f <chr>, Q13a <chr>, Q13b <chr>, Q13c <chr>, Q13d <chr>, Q13e <chr>, Q14a <chr>, Q14b <chr>, Q14c <chr>, Q14d <chr>,
## #   Q14e <chr>, Q15a <chr>, Q15b <chr>, Q15c <chr>, Q15d <chr>, Q15e <chr>, Q16a <chr>, Q16b <chr>, Q16c <chr>, Q16d <chr>,
## #   Q16e <chr>, Q17a <chr>, Q17b <chr>, Q17c <chr>, Q17d <chr>, Q17e <chr>, Q18a <chr>, Q18b <chr>, Q18c <chr>, Q18d <chr>,
## #   Q18e <chr>, Q19 <chr>, Q20 <chr>, Q21 <chr>, Q22 <chr>, Q22_4_text <chr>, Q23 <chr>, Q24a <chr>, Q24b <chr>, Q24c <chr>,
## #   Q24d <chr>, Q24e <chr>, Q24f <chr>, Q24g <chr>, Q24h <chr>, Q24i <chr>, Q24j <chr>, Q24k <chr>, Q24l <chr>, …

Description:

#For those who did not move only one slider for question 7, insert 50 (midpoint - half savings, half loans) as the selected value

mydata$Q7a_1 <- ifelse((mydata$Q7a_1==-1)&(mydata$Q7b_1!=-1)&(mydata$Q7c_1!=-1)&(mydata$Q7d_1!=-1)&(mydata$Q7e_1!=-1)&(mydata$Q7f_1!=-1),50, mydata$Q7a_1)

mydata$Q7b_1 <- ifelse((mydata$Q7a_1!=-1)&(mydata$Q7b_1==-1)&(mydata$Q7c_1!=-1)&(mydata$Q7d_1!=-1)&(mydata$Q7e_1!=-1)&(mydata$Q7f_1!=-1),50,mydata$Q7b_1)

mydata$Q7c_1 <- ifelse((mydata$Q7a_1!=-1)&(mydata$Q7b_1!=-1)&(mydata$Q7c_1==-1)&(mydata$Q7d_1!=-1)&(mydata$Q7e_1!=-1)&(mydata$Q7f_1!=-1),50,mydata$Q7c_1)

mydata$Q7d_1 <- ifelse((mydata$Q7a_1!=-1)&(mydata$Q7b_1!=-1)&(mydata$Q7c_1!=-1)&(mydata$Q7d_1==-1)&(mydata$Q7e_1!=-1)&(mydata$Q7f_1!=-1),50,mydata$Q7d_1)

mydata$Q7e_1 <- ifelse((mydata$Q7a_1!=-1)&(mydata$Q7b_1!=-1)&(mydata$Q7c_1!=-1)&(mydata$Q7d_1!=-1)&(mydata$Q7e_1==-1)&(mydata$Q7f_1!=-1),50,mydata$Q7e_1)

mydata$Q7f_1 <- ifelse((mydata$Q7a_1!=-1)&(mydata$Q7b_1!=-1)&(mydata$Q7c_1!=-1)&(mydata$Q7d_1!=-1)&(mydata$Q7e_1!=-1)&(mydata$Q7f_1==-1),50,mydata$Q7f_1)
#Identify values -1,-3 and replace them with NA. Identify also the -2
# -1 means: The person has not answered the specific question
# -2 means: Person did not respond because it did not satisfy if sentence
# -3 means: Person stopped answering questionnaire before coming to this sentence

mydata[mydata == -1] <- NA
mydata[mydata == -3] <- NA

# Get rid of those that are under 18 and over 27
mydata_t1<-mydata[!(mydata$Q2=="-2"),]

#solve some problems with 1ka (illogical -2 values)
mydata_t1 <- mydata_t1[!(mydata_t1$Q13a=="-2"),]

mydata_dropNA<-mydata_t1
mydata_dropNA <- na.omit(mydata_dropNA)
# convert character to integer, except the variables where Other was typed in
mydata_dropNA <- mydata_dropNA %>% 
mutate_at(c(2:33), as.integer)
mydata_dropNA <- mydata_dropNA %>% 
mutate_at(c(35:74), as.integer)
mydata_dropNA <- mydata_dropNA %>% 
mutate_at(c(76:88), as.integer)
mydata_dropNA <- mydata_dropNA %>% 
mutate_at(c(89:93), as.integer)
## Warning in mask$eval_all_mutate(quo): NAs introduced by coercion
mydata_dropNA$Q1 <- mydata_dropNA$Q1 + 16

Transform fo factors

mydata_dropNA$Sex_F <- factor(mydata_dropNA$Q19,
                             levels = c(1, 2,3),
                             labels = c("Female", "Male", "Other"))

mydata_dropNA$Region_F <- factor(mydata_dropNA$Q20, 
                            levels = c(1,2, 3, 4, 5, 6, 7, 8, 9), 
                            labels = c("Ljubljana z okolico","Štajerska","Prekmurje", "Dolenjska","Primorska" , "Gorenjska" , "Goriška", "Koroška" , "Notranjska"))

mydata_dropNA$Status_F <- factor(mydata_dropNA$Q22, 
                            levels = c(1,2, 3), 
                            labels = c("Single","In a relationship","Married"))

mydata_dropNA$Children_F <- factor(mydata_dropNA$Q23, 
                          levels = c(2, 1), 
                          labels = c("No", "Yes"))

mydata_dropNA$Education_F <- factor(mydata_dropNA$Q25, 
                           levels = c(1,2,3,4,5), 
                           labels = c("Primary school", "High school", "Vocational School", "Undergraduate", "Post-Graduate"))

mydata_dropNA$Employed_F <- factor(mydata_dropNA$Q26, 
                          levels = c(2, 1), 
                          labels = c("No", "Yes"))
head(mydata_dropNA)
## # A tibble: 6 × 99
##      ID    Q1    Q2    Q3    Q4    Q5   Q6a   Q6b   Q6c   Q6d Q7a_1 Q7b_1 Q7c_1 Q7d_1 Q7e_1 Q7f_1   Q8a   Q8b   Q8c   Q8d   Q9a
##   <int> <dbl> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
## 1     1    23     2    -2    -2    -2     1     5     5     5     7    10    16    16    16    80     3     5     2     4     5
## 2     2    22     2    -2    -2    -2     3     4     5     3     0    22    59     0    23    57     4     4     1     4     5
## 3     3    21     2    -2    -2    -2     4     4     3     3     0    26    63    17     0   100     4     2     2     4     4
## 4     4    23     1     3     4     2     5     4     3     2    82     0    85    63    85   100     5     4     1     4     5
## 5     5    23     2    -2    -2    -2     4     2     4     5     0     0     0     0    25    50     5     1     1     1     5
## 6     6    23     1     3     4     2     4     4     4     2     0     0    50     0     0    70     4     4     1     2     5
## # … with 78 more variables: Q9b <int>, Q9c <int>, Q9d <int>, Q10a <int>, Q10b <int>, Q10c <int>, Q10d <int>, Q10e <int>,
## #   Q10f <int>, Q10g <int>, Q10h <int>, Q11 <int>, Q11_9_text <chr>, Q12a <int>, Q12b <int>, Q12c <int>, Q12d <int>, Q12e <int>,
## #   Q12f <int>, Q13a <int>, Q13b <int>, Q13c <int>, Q13d <int>, Q13e <int>, Q14a <int>, Q14b <int>, Q14c <int>, Q14d <int>,
## #   Q14e <int>, Q15a <int>, Q15b <int>, Q15c <int>, Q15d <int>, Q15e <int>, Q16a <int>, Q16b <int>, Q16c <int>, Q16d <int>,
## #   Q16e <int>, Q17a <int>, Q17b <int>, Q17c <int>, Q17d <int>, Q17e <int>, Q18a <int>, Q18b <int>, Q18c <int>, Q18d <int>,
## #   Q18e <int>, Q19 <int>, Q20 <int>, Q21 <int>, Q22 <int>, Q22_4_text <chr>, Q23 <int>, Q24a <int>, Q24b <int>, Q24c <int>,
## #   Q24d <int>, Q24e <int>, Q24f <int>, Q24g <int>, Q24h <int>, Q24i <int>, Q24j <int>, Q24k <int>, Q24l <int>, …
#mydata_dropNA <- mydata_dropNA[-c(255, 231, 107, 180, 188, 124),]
mydata_dropNA <- mydata_dropNA[-c(255, 231, 107),]
summary(mydata_dropNA[c("Q6c", "Q12a", "Q12d", "Q12f","Q18a")])
##       Q6c             Q12a            Q12d            Q12f            Q18a     
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.00  
##  1st Qu.:4.000   1st Qu.:2.000   1st Qu.:4.000   1st Qu.:3.000   1st Qu.:2.00  
##  Median :4.000   Median :3.000   Median :4.000   Median :3.000   Median :2.00  
##  Mean   :4.206   Mean   :2.709   Mean   :3.977   Mean   :3.268   Mean   :2.33  
##  3rd Qu.:5.000   3rd Qu.:3.000   3rd Qu.:5.000   3rd Qu.:4.000   3rd Qu.:3.00  
##  Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.00
library(Hmisc)
rcorr(as.matrix(mydata_dropNA[ , c("Q6c", "Q10a", "Q12d", "Q12f","Q18a")]), 
      type = "pearson") 
##        Q6c  Q10a  Q12d  Q12f  Q18a
## Q6c   1.00 -0.06 -0.02 -0.02 -0.01
## Q10a -0.06  1.00 -0.04  0.16  0.15
## Q12d -0.02 -0.04  1.00  0.10 -0.11
## Q12f -0.02  0.16  0.10  1.00  0.11
## Q18a -0.01  0.15 -0.11  0.11  1.00
## 
## n= 306 
## 
## 
## P
##      Q6c    Q10a   Q12d   Q12f   Q18a  
## Q6c         0.2729 0.7478 0.6755 0.8493
## Q10a 0.2729        0.5000 0.0055 0.0077
## Q12d 0.7478 0.5000        0.0849 0.0600
## Q12f 0.6755 0.0055 0.0849        0.0482
## Q18a 0.8493 0.0077 0.0600 0.0482
mydata_std <- as.data.frame(scale(mydata_dropNA[c("Q6c", "Q10f", "Q12e", "Q12c", "Q12f")]))
mydata_std$Dissimilarity <- sqrt(mydata_std$Q6c^2 + mydata_std$Q10f^2 + mydata_std$Q12e^2 + mydata_std$Q12c^2 + mydata_std$Q12f^2)
head(mydata_std[order(-mydata_std$Dissimilarity), ], 5) #Finding top 5 objects with highest value of dissimilarity
##            Q6c       Q10f      Q12e      Q12c       Q12f Dissimilarity
## 149 -3.7574417  0.2852401 -1.887315  1.056008 -1.3475885      4.548938
## 296  0.9307424 -2.6568991  1.398707 -2.011763 -2.4103775      4.442846
## 293 -3.7574417  0.2852401 -1.887315  1.056008 -0.2847996      4.354073
## 179  0.9307424 -2.6568991 -1.065810 -2.011763 -2.4103775      4.349535
## 30   0.9307424 -1.6761860 -1.887315 -2.011763 -2.4103775      4.134604
mydata1 <- mydata_std
library(factoextra) 

#Finding Eudlidean distances, based on 6 Cluster variables, then saving them into object Distances
Distances <- get_dist(mydata1, 
                      method = "euclidian")

Distances2 <- Distances^2

fviz_dist(Distances2) #Showing matrix of distances

library(factoextra) 
get_clust_tendency(mydata1, #Hopkins statistics
                   n = nrow(mydata1) - 1,
                   graph = FALSE) 
## $hopkins_stat
## [1] 0.6183736
## 
## $plot
## NULL
library(dplyr)
WARD <- mydata1 %>% #Selecting variables
  get_dist(method = "euclidean") %>%  #Selecting distance
  hclust(method = "ward.D2") #Selecting algorithm         

WARD
## 
## Call:
## hclust(d = ., method = "ward.D2")
## 
## Cluster method   : ward.D2 
## Distance         : euclidean 
## Number of objects: 306
library(factoextra)
fviz_dend(WARD) #Dendrogram
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as of ggplot2 3.3.4.
## ℹ The deprecated feature was likely used in the factoextra package.
##   Please report the issue at <]8;;https://github.com/kassambara/factoextra/issueshttps://github.com/kassambara/factoextra/issues]8;;>.

set.seed(1)
#install.packages("NbClust")
library(NbClust)
OptNumber <- mydata1[c("Q6c", "Q10f", "Q12e", "Q12c", "Q12f")] %>%
  #scale() %>%
  NbClust(distance = "euclidean",
          min.nc = 2, max.nc = 10, 
          method = "ward.D2", 
          index = "all") 

## *** : The Hubert index is a graphical method of determining the number of clusters.
##                 In the plot of Hubert index, we seek a significant knee that corresponds to a 
##                 significant increase of the value of the measure i.e the significant peak in Hubert
##                 index second differences plot. 
## 

## *** : The D index is a graphical method of determining the number of clusters. 
##                 In the plot of D index, we seek a significant knee (the significant peak in Dindex
##                 second differences plot) that corresponds to a significant increase of the value of
##                 the measure. 
##  
## ******************************************************************* 
## * Among all indices:                                                
## * 7 proposed 2 as the best number of clusters 
## * 7 proposed 3 as the best number of clusters 
## * 1 proposed 4 as the best number of clusters 
## * 4 proposed 5 as the best number of clusters 
## * 1 proposed 6 as the best number of clusters 
## * 1 proposed 7 as the best number of clusters 
## * 1 proposed 9 as the best number of clusters 
## * 2 proposed 10 as the best number of clusters 
## 
##                    ***** Conclusion *****                            
##  
## * According to the majority rule, the best number of clusters is  2 
##  
##  
## *******************************************************************
mydata1$ClusterWard <- cutree(WARD, 
                             k = 5) #Number of groups

head(mydata1[c( "ClusterWard")])
##   ClusterWard
## 1           1
## 2           1
## 3           2
## 4           1
## 5           3
## 6           1
#Calculating positions of initial leaders

Initial_leaders <- aggregate(mydata1[, c("Q6c", "Q10f", "Q12e", "Q12c", "Q12f")], 
                            by = list(mydata1$ClusterWard), 
                            FUN = mean)

Initial_leaders
##   Group.1         Q6c       Q10f        Q12e       Q12c        Q12f
## 1       1  0.20888627  0.3047244  0.39766732  0.1282277  0.03896387
## 2       2 -0.09984976  0.3359666 -1.13662902  0.4389279  0.50313006
## 3       3  0.04456129 -1.6522662  0.03621015 -0.1661118  0.36324237
## 4       4  0.58229632 -0.1918636  0.35517311 -1.3208232 -1.43376062
## 5       5 -2.58539564  0.4917060 -0.46048964  0.5716234  0.16269042
library(factoextra) 

kmeans_clu <- hkmeans(mydata1, #Data
                      k = 5, #Number of groups
                      hc.metric = "euclidean", #Distance for hierar. clus.
                      hc.method = "ward.D2") #Algorithm for hierar. clus.

kmeans_clu
## Hierarchical K-means clustering with 5 clusters of sizes 145, 68, 38, 36, 19
## 
## Cluster means:
##           Q6c       Q10f       Q12e       Q12c        Q12f Dissimilarity ClusterWard
## 1  0.17093328  0.3122942  0.4752216  0.1180461  0.05969056      1.658045    1.013793
## 2  0.03447194  0.2708178 -1.1745383  0.3943322  0.44977504      1.991227    1.941176
## 3  0.03628625 -1.8052272  0.1448303 -0.1549539  0.24659481      2.578303    3.026316
## 4  0.57261726 -0.1233904  0.3946449 -1.3584410 -1.43615429      2.800810    4.000000
## 5 -2.58539564  0.4917060 -0.4604896  0.5716234  0.16269042      3.355302    5.000000
## 
## Clustering vector:
##   [1] 1 1 2 1 3 1 4 1 1 2 2 2 2 3 1 4 4 3 2 1 1 2 1 3 2 2 1 1 2 4 1 1 1 1 1 1 5 2 3 2 2 4 2 1 1 1 1 5 2 2 1 1 1 5 1 2 1 1 1 2 1 4
##  [63] 1 1 5 5 1 3 2 1 1 5 3 3 1 5 2 3 1 1 2 2 1 5 1 2 1 2 1 1 2 1 1 1 1 1 1 1 2 2 1 3 2 1 1 1 2 2 1 3 1 1 2 1 4 3 1 2 1 2 1 1 4 1
## [125] 1 2 1 3 1 3 2 1 1 1 5 1 1 1 1 2 1 2 1 3 3 1 1 4 5 1 4 2 1 3 1 1 2 5 1 2 4 1 3 2 1 2 1 1 2 1 1 2 2 3 1 3 1 1 4 1 3 4 1 1 1 2
## [187] 4 1 1 2 1 1 1 4 3 4 3 1 1 2 3 4 4 2 2 2 3 1 2 3 1 2 3 5 1 5 2 1 3 1 1 1 1 1 3 1 1 1 3 4 1 4 1 1 1 1 4 3 2 4 4 2 1 1 4 1 1 5
## [249] 1 3 3 1 1 1 1 2 1 5 1 2 2 1 4 2 1 3 1 1 1 2 4 5 3 4 1 1 2 1 1 4 1 1 5 4 4 4 2 3 2 5 1 1 5 4 4 4 3 2 4 1 2 2 3 1 4 2
## 
## Within cluster sum of squares by cluster:
## [1] 452.48743 186.53702 158.76818 160.49630  83.51133
##  (between_SS / total_SS =  53.2 %)
## 
## Available components:
## 
##  [1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss" "betweenss"    "size"         "iter"        
##  [9] "ifault"       "data"         "hclust"
library(factoextra)
fviz_cluster(kmeans_clu, 
             palette = "Set1", 
             repel = FALSE,
             ggtheme = theme_bw())

mydata1$ClusterK_Means <- kmeans_clu$cluster
head(mydata1[c( "ClusterWard", "ClusterK_Means")])
##   ClusterWard ClusterK_Means
## 1           1              1
## 2           1              1
## 3           2              2
## 4           1              1
## 5           3              3
## 6           1              1
#Checking for reclassifications
table(mydata1$ClusterWard)
## 
##   1   2   3   4   5 
## 151  58  41  37  19
table(mydata1$ClusterK_Means)
## 
##   1   2   3   4   5 
## 145  68  38  36  19
table(mydata1$ClusterWard, mydata1$ClusterK_Means)
##    
##       1   2   3   4   5
##   1 143   8   0   0   0
##   2   2  56   0   0   0
##   3   0   4  37   0   0
##   4   0   0   1  36   0
##   5   0   0   0   0  19
Centroids <- kmeans_clu$centers
Centroids
##           Q6c       Q10f       Q12e       Q12c        Q12f Dissimilarity ClusterWard
## 1  0.17093328  0.3122942  0.4752216  0.1180461  0.05969056      1.658045    1.013793
## 2  0.03447194  0.2708178 -1.1745383  0.3943322  0.44977504      1.991227    1.941176
## 3  0.03628625 -1.8052272  0.1448303 -0.1549539  0.24659481      2.578303    3.026316
## 4  0.57261726 -0.1233904  0.3946449 -1.3584410 -1.43615429      2.800810    4.000000
## 5 -2.58539564  0.4917060 -0.4604896  0.5716234  0.16269042      3.355302    5.000000
library(ggplot2)
library(tidyr)
## 
## Attaching package: 'tidyr'
## The following object is masked from 'package:magrittr':
## 
##     extract
Figure <- as.data.frame(Centroids)
Figure$id <- 1:nrow(Figure)
Figure <- pivot_longer(Figure, cols = c(Q6c, Q10f, Q12e, Q12c, Q12f))

Figure$Groups <- factor(Figure$id, 
                        levels = c(1, 2, 3, 4, 5), 
                        labels = c("1", "2", "3", "4", "5"))

Figure$nameFactor <- factor(Figure$name, 
                            levels = c("Q6c", "Q10f", "Q12e", "Q12c", "Q12f"), 
                            labels = c("Q6c", "Q10f", "Q12e", "Q12c", "Q12f"))

ggplot(Figure, aes(x = nameFactor, y = value)) +
  geom_hline(yintercept = 0) +
  theme_bw() +
  geom_point(aes(shape = Groups, col = Groups), size = 3) +
  geom_line(aes(group = id), linewidth = 1) +
  ylab("Averages") +
  xlab("Cluster variables")+
  ylim(-2.7, 1.0)

#Checking if clustering variables successfully differentiate between groups

fit <- aov(cbind(Q6c, Q10f, Q12e, Q12c, Q12f) ~ as.factor(ClusterK_Means), 
           data = mydata1)

summary(fit)
##  Response Q6c :
##                            Df Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   4 143.17  35.793  66.576 < 2.2e-16 ***
## Residuals                 301 161.83   0.538                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q10f :
##                            Df Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   4 148.11  37.027  71.036 < 2.2e-16 ***
## Residuals                 301 156.89   0.521                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q12e :
##                            Df Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   4 136.99  34.247  61.355 < 2.2e-16 ***
## Residuals                 301 168.01   0.558                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q12c :
##                            Df  Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   4  86.148 21.5370  29.621 < 2.2e-16 ***
## Residuals                 301 218.852  0.7271                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q12f :
##                            Df  Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   4  91.338 22.8345  32.168 < 2.2e-16 ***
## Residuals                 301 213.662  0.7098                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aggregate(mydata_dropNA$Q28,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 2.386207
## 2       2 1.823529
## 3       3 2.236842
## 4       4 2.111111
## 5       5 1.526316
fit <- aov(mydata_dropNA$Q28 ~ as.factor(ClusterK_Means), 
           data = mydata1)

summary(fit)
##                            Df Sum Sq Mean Sq F value Pr(>F)  
## as.factor(ClusterK_Means)   4   23.1   5.764   2.924 0.0214 *
## Residuals                 301  593.4   1.971                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aggregate(mydata_dropNA$Q24b,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1         x
## 1       1 0.4344828
## 2       2 0.4558824
## 3       3 0.3947368
## 4       4 0.4166667
## 5       5 0.4736842
aggregate(mydata_dropNA$Q25,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 3.420690
## 2       2 3.176471
## 3       3 2.947368
## 4       4 3.138889
## 5       5 3.789474
aggregate(mydata_dropNA$Q9a,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 4.317241
## 2       2 4.838235
## 3       3 3.842105
## 4       4 4.194444
## 5       5 4.631579
aggregate(mydata_dropNA$Q22,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 1.434483
## 2       2 1.544118
## 3       3 1.605263
## 4       4 1.861111
## 5       5 1.578947
aggregate(mydata_dropNA$Q10h,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 3.979310
## 2       2 3.808824
## 3       3 3.210526
## 4       4 4.333333
## 5       5 4.421053