# import an excel file
mydata <- read_excel("C:/Users/eneja/OneDrive/Namizje/IMB R/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(112, 27, 212, 16, 216, 87, 291, 39, 188, 280, 300, 299, 3, 190, 140, 225, 103, 278, 101, 4, 217, 100, 171, 185, 211, 168, 167),]
summary(mydata_dropNA[c("Q12f", "Q12a", "Q10a", "Q10f","Q10g")])
##       Q12f            Q12a            Q10a            Q10f            Q10g      
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:3.000   1st Qu.:2.000   1st Qu.:3.000   1st Qu.:3.000   1st Qu.:3.000  
##  Median :3.000   Median :3.000   Median :4.000   Median :4.000   Median :4.000  
##  Mean   :3.246   Mean   :2.693   Mean   :3.706   Mean   :3.689   Mean   :3.557  
##  3rd Qu.:4.000   3rd Qu.:3.000   3rd Qu.:4.000   3rd Qu.:4.000   3rd Qu.:4.000  
##  Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000
library(Hmisc)
rcorr(as.matrix(mydata_dropNA[ , c("Q12f", "Q12a", "Q10a", "Q10f","Q10g")]), 
      type = "pearson") 
##      Q12f Q12a Q10a Q10f Q10g
## Q12f 1.00 0.37 0.20 0.17 0.01
## Q12a 0.37 1.00 0.19 0.20 0.09
## Q10a 0.20 0.19 1.00 0.26 0.02
## Q10f 0.17 0.20 0.26 1.00 0.33
## Q10g 0.01 0.09 0.02 0.33 1.00
## 
## n= 309 
## 
## 
## P
##      Q12f   Q12a   Q10a   Q10f   Q10g  
## Q12f        0.0000 0.0003 0.0021 0.9296
## Q12a 0.0000        0.0008 0.0004 0.1102
## Q10a 0.0003 0.0008        0.0000 0.7763
## Q10f 0.0021 0.0004 0.0000        0.0000
## Q10g 0.9296 0.1102 0.7763 0.0000
mydata_std <- as.data.frame(scale(mydata_dropNA[c("Q12f", "Q12a", "Q10a", "Q10f","Q10g")]))
#mydata_std$Dissimilarity <- sqrt(mydata_std$Q12f^2 + mydata_std$Q12a^2 + mydata_std$Q10a^2 + mydata_std$Q10f^2 + mydata_std$Q10g^2)
#head(mydata_std[order(-mydata_std$Dissimilarity), ], 5) #Finding top 5 objects with highest value of dissimilarity
#mydata_dropNA <- mydata_dropNA[-c(39, 179),]
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.5365047
## 
## $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: 309
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("Q12f", "Q12a", "Q10a", "Q10f","Q10g")] %>%
  #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:                                                
## * 6 proposed 2 as the best number of clusters 
## * 9 proposed 3 as the best number of clusters 
## * 2 proposed 4 as the best number of clusters 
## * 2 proposed 7 as the best number of clusters 
## * 4 proposed 10 as the best number of clusters 
## 
##                    ***** Conclusion *****                            
##  
## * According to the majority rule, the best number of clusters is  3 
##  
##  
## *******************************************************************
mydata1$ClusterWard <- cutree(WARD, 
                             k = 4) #Number of groups

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

Initial_leaders <- aggregate(mydata1[, c("Q12f", "Q12a", "Q10a", "Q10f","Q10g")], 
                            by = list(mydata1$ClusterWard), 
                            FUN = mean)

Initial_leaders
##   Group.1        Q12f        Q12a       Q10a       Q10f       Q10g
## 1       1  0.46680896  0.84433703  0.1711896  0.5834527  0.4412628
## 2       2 -0.80102794 -0.95014985 -1.8107988 -1.0007866 -0.1160526
## 3       3 -0.07326677 -0.08358824  0.1897904 -0.4610423 -0.6686174
## 4       4 -0.17242822 -0.82240671  0.6564186  0.6265551  0.6906379
library(factoextra) 

kmeans_clu <- hkmeans(mydata1, #Data
                      k = 4, #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 4 clusters of sizes 105, 41, 108, 55
## 
## Cluster means:
##          Q12f       Q12a       Q10a       Q10f        Q10g ClusterWard
## 1  0.46680896  0.8443370  0.1711896  0.5834527  0.44126283    1.000000
## 2 -0.83840688 -0.9968851 -1.8328144 -0.8751368  0.02533057    2.097561
## 3 -0.01503778 -0.0078471  0.2024982 -0.5478557 -0.75196831    2.972222
## 4 -0.23665779 -0.8533747  0.6418305  0.6142997  0.61529868    3.909091
## 
## Clustering vector:
##   [1] 1 1 1 2 3 3 3 3 4 1 3 1 1 3 3 4 4 2 2 1 1 1 3 2 3 3 1 3 2 2 4 4 3 3 1 1 1 2 2 1 3 4 1 3 1 1 1 1 1 1 4 1 1 4 3 3 4 3 3 4 3 2
##  [63] 4 1 3 1 1 3 1 1 3 1 3 3 1 1 1 2 4 1 4 1 1 3 1 4 3 1 1 3 1 1 1 1 4 1 3 3 1 1 1 3 4 3 3 1 2 1 3 1 3 1 3 3 1 3 2 4 3 4 1 1 2 2
## [125] 1 1 1 3 3 4 3 4 1 3 3 4 4 3 2 3 1 2 1 1 3 3 3 1 3 4 4 3 3 4 3 1 4 1 4 3 1 1 3 3 1 3 4 2 1 4 4 3 1 1 3 1 3 1 3 2 4 3 2 1 3 3
## [187] 1 2 1 3 1 3 1 1 2 3 3 2 3 3 2 3 3 1 1 3 3 3 3 3 2 3 1 3 4 3 1 1 1 3 4 1 1 3 2 3 3 3 2 3 2 3 1 2 3 3 1 1 2 3 1 1 2 4 4 4 3 4
## [249] 1 4 2 2 2 1 2 1 3 3 3 3 1 4 4 1 2 3 4 1 3 1 4 4 1 2 4 3 1 3 3 1 2 2 2 4 4 1 1 2 3 4 3 4 4 4 4 1 4 3 3 2 3 4 1 1 3 3 4 4 3
## 
## Within cluster sum of squares by cluster:
## [1] 227.7933 220.3647 372.5455 129.3344
##  (between_SS / total_SS =  50.5 %)
## 
## 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 = TRUE,
             ggtheme = theme_bw())
## Warning: ggrepel: 234 unlabeled data points (too many overlaps). Consider increasing max.overlaps

mydata1$ClusterK_Means <- kmeans_clu$cluster
head(mydata1[c( "ClusterWard", "ClusterK_Means")])
##   ClusterWard ClusterK_Means
## 1           1              1
## 2           1              1
## 3           1              1
## 4           2              2
## 5           3              3
## 6           3              3
#Checking for reclassifications
table(mydata1$ClusterWard)
## 
##   1   2   3   4 
## 105  40 114  50
table(mydata1$ClusterK_Means)
## 
##   1   2   3   4 
## 105  41 108  55
table(mydata1$ClusterWard, mydata1$ClusterK_Means)
##    
##       1   2   3   4
##   1 105   0   0   0
##   2   0  37   3   0
##   3   0   4 105   5
##   4   0   0   0  50
Centroids <- kmeans_clu$centers
Centroids
##          Q12f       Q12a       Q10a       Q10f        Q10g ClusterWard
## 1  0.46680896  0.8443370  0.1711896  0.5834527  0.44126283    1.000000
## 2 -0.83840688 -0.9968851 -1.8328144 -0.8751368  0.02533057    2.097561
## 3 -0.01503778 -0.0078471  0.2024982 -0.5478557 -0.75196831    2.972222
## 4 -0.23665779 -0.8533747  0.6418305  0.6142997  0.61529868    3.909091
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(Q12f, Q12a, Q10a, Q10f, Q10g))

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

Figure$nameFactor <- factor(Figure$name, 
                            levels = c("Q12f", "Q12a", "Q10a", "Q10f","Q10g"), 
                            labels = c("Transparency", "Reputation", "B_Consultant", "Bank_website", "Literature"))

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.0, 1.5)

#Checking if clustering variables successfully differentiate between groups

fit <- aov(cbind(Q12f, Q12a, Q10a, Q10f, Q10g) ~ as.factor(ClusterK_Means), 
           data = mydata1)

summary(fit)
##  Response Q12f :
##                            Df  Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   3  54.805 18.2685  22.006 6.302e-13 ***
## Residuals                 305 253.195  0.8301                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q12a :
##                            Df Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   3 155.66  51.887  103.88 < 2.2e-16 ***
## Residuals                 305 152.34   0.499                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q10a :
##                            Df Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   3 167.89  55.963  121.82 < 2.2e-16 ***
## Residuals                 305 140.11   0.459                      
## ---
## 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)   3 120.31  40.105  65.173 < 2.2e-16 ***
## Residuals                 305 187.69   0.615                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response Q10g :
##                            Df Sum Sq Mean Sq F value    Pr(>F)    
## as.factor(ClusterK_Means)   3 102.36  34.121  50.608 < 2.2e-16 ***
## Residuals                 305 205.64   0.674                      
## ---
## 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.190476
## 2       2 1.634146
## 3       3 2.453704
## 4       4 1.890909
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)   3   24.7   8.242   4.205 0.00618 **
## Residuals                 305  597.8   1.960                   
## ---
## 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.3809524
## 2       2 0.4390244
## 3       3 0.4722222
## 4       4 0.4909091
aggregate(mydata_dropNA$Q25,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 3.476190
## 2       2 3.097561
## 3       3 3.129630
## 4       4 3.472727
aggregate(mydata_dropNA$Q9a,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 4.600000
## 2       2 3.707317
## 3       3 4.296296
## 4       4 4.436364
aggregate(mydata_dropNA$Q22,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 1.495238
## 2       2 1.658537
## 3       3 1.537037
## 4       4 1.563636
aggregate(mydata_dropNA$Q26,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 1.580952
## 2       2 1.560976
## 3       3 1.620370
## 4       4 1.618182
aggregate(mydata_dropNA$Q23,
          by = list(mydata1$ClusterK_Means),
          FUN = "mean")
##   Group.1        x
## 1       1 1.971429
## 2       2 1.975610
## 3       3 1.981481
## 4       4 1.945455