date()
## [1] "Wed Apr 24 16:31:21 2024"
options(scipen = 999)

Озабоченность эко проблемами

  • denial - отрицание

  • intern - интернализм

  • biocentrism - биоцентризм

  • money - деньги

  • summotiv - сумма общей озабоченности

Мотивация взаимодействия с природой

  • aesthetic - эстетическая

  • cogn - когнитивная

  • pract - практическая

  • progmat - прогматическая

Агрессивность

  • dverb - direct verbal - прямая вербальная А

  • indverb - indirect verbal - непрямая вербальная А

  • indph - indirect physical - непрямая физическая А

  • dph - direct physical - прямая физическая А

  • sumaggress - сумма общей агрессивности

пол и возраст

Libraries

library(kableExtra)
library(reshape2)
library(ggplot2)
library(dplyr)
## 
## Присоединяю пакет: 'dplyr'
## Следующий объект скрыт от 'package:kableExtra':
## 
##     group_rows
## Следующие объекты скрыты от 'package:stats':
## 
##     filter, lag
## Следующие объекты скрыты от 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
## 
## Присоединяю пакет: 'tidyr'
## Следующий объект скрыт от 'package:reshape2':
## 
##     smiths
library(Hmisc)
## Warning: пакет 'Hmisc' был собран под R версии 4.3.3
## 
## Присоединяю пакет: 'Hmisc'
## Следующие объекты скрыты от 'package:dplyr':
## 
##     src, summarize
## Следующие объекты скрыты от 'package:base':
## 
##     format.pval, units

Корреляционная матрица с уровнем значимости р<0.5

correlation_matrix <- cor(df)

p_values <- matrix(NA, nrow = ncol(df), ncol = ncol(df))
rownames(p_values) <- colnames(p_values) <- colnames(df)

for (i in 1:(ncol(df) - 1)) {
  for (j in (i + 1):ncol(df)) {
    cor_test_result <- cor.test(df[[i]], df[[j]])
    p_values[i, j] <- p_values[j, i] <- cor_test_result$p.value
  }
}

significant_level <- 0.05
significant <- ifelse(p_values < significant_level, "*", "")

cor_matrix_with_significance <- round(correlation_matrix, 2)
cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)] <- paste(cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)], significant[lower.tri(significant)], sep = "")

cor_df <- as.data.frame(cor_matrix_with_significance)
cor_df <- cor_df[-1, -1]
cor_df_html <- kable(cor_df, format = "html")
kable_styling(cor_df_html)
age denial intern biocentrism money summotiv aesthetic cogn pract progmat dverb indverb indph dph sumaggress
age 1 -0.08 -0.18 0.09 -0.15 0.06 0.03 0.04 0.11 -0.18 0.13 0.02 -0.08 0.08 0.05
denial -0.08 1 -0.2 -0.68 0.62 -0.82 0.03 -0.13 -0.07 0.16 0.02 -0.06 -0.04 0.16 0.02
intern -0.18 -0.2 1 0.26 -0.05 0.45 0.06 -0.11 0.04 0.02 -0.06 0.08 0.04 0.02 0.01
biocentrism 0.09 -0.68* 0.26* 1 -0.73 0.89 0.05 0.12 0.17 -0.35 -0.21 -0.02 -0.12 -0.29 -0.22
money -0.15 0.62* -0.05 -0.73* 1 -0.83 -0.1 -0.01 0 0.14 0.17 0.16 0.07 0.17 0.14
summotiv 0.06 -0.82* 0.45* 0.89* -0.83* 1 0.06 0.06 0.08 -0.22 -0.16 -0.02 -0.04 -0.22 -0.14
aesthetic 0.03 0.03 0.06 0.05 -0.1 0.06 1 -0.46 -0.52 -0.24 0.01 -0.14 0.05 0.06 0.03
cogn 0.04 -0.13 -0.11 0.12 -0.01 0.06 -0.46* 1 -0.05 -0.42 -0.22 -0.06 -0.03 -0.17 -0.17
pract 0.11 -0.07 0.04 0.17 0 0.08 -0.52* -0.05 1 -0.29 -0.03 0.28 -0.15 -0.09 -0.08
progmat -0.18 0.16 0.02 -0.35* 0.14 -0.22 -0.24* -0.42* -0.29* 1 0.23 -0.05 0.11 0.19 0.21
dverb 0.13 0.02 -0.06 -0.21 0.17 -0.16 0.01 -0.22 -0.03 0.23* 1 0.51 0.42 0.55 0.81
indverb 0.02 -0.06 0.08 -0.02 0.16 -0.02 -0.14 -0.06 0.28* -0.05 0.51* 1 0.38 0.32 0.5
indph -0.08 -0.04 0.04 -0.12 0.07 -0.04 0.05 -0.03 -0.15 0.11 0.42* 0.38* 1 0.58 0.78
dph 0.08 0.16 0.02 -0.29* 0.17 -0.22 0.06 -0.17 -0.09 0.19 0.55* 0.32* 0.58* 1 0.85
sumaggress 0.05 0.02 0.01 -0.22* 0.14 -0.14 0.03 -0.17 -0.08 0.21 0.81* 0.5* 0.78* 0.85* 1

Корреляционная матрица с уровнем значимости р<0.5 для ведущих мотиваций

clusteraesthetic <- subset(df_full, cluster_aesthetic == 1)
clusterpract <- subset(df_full, cluster_pract == 1)
clustercogn <- subset(df_full, cluster_cogn == 1)
clusterprogmat <- subset(df_full, cluster_progmat == 1)

clusteraesthetic <- clusteraesthetic[, -c(17:22)]
clustercogn <- clustercogn[, -c(17:22)]
clusterpract <- clusterpract[, -c(17:22)]
clusterprogmat <- clusterprogmat[, -c(17:22)]

#корреляции для ведущей мотивации - эстетическая
p_values <- matrix(NA, nrow = ncol(clusteraesthetic), ncol = ncol(clusteraesthetic))
rownames(p_values) <- colnames(p_values) <- colnames(clusteraesthetic)

for (i in 1:(ncol(clusteraesthetic) - 1)) {
  for (j in (i + 1):ncol(clusteraesthetic)) {
    cor_test_result <- cor.test(clusteraesthetic[[i]], clusteraesthetic[[j]])
    p_values[i, j] <- p_values[j, i] <- cor_test_result$p.value
  }
}

significant_level <- 0.05
significant <- ifelse(p_values < significant_level, "*", "")

cor_matrix_with_significance <- round(correlation_matrix, 2)
cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)] <- paste(cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)], significant[lower.tri(significant)], sep = "")

cor_clusteraesthetic <- as.data.frame(cor_matrix_with_significance)
cor_clusteraesthetic <- cor_clusteraesthetic[-1, -1]
cor_clusteraesthetic_html <- kable(cor_clusteraesthetic, format = "html")
kable_styling(cor_clusteraesthetic_html)
age denial intern biocentrism money summotiv aesthetic cogn pract progmat dverb indverb indph dph sumaggress
age 1 -0.08 -0.18 0.09 -0.15 0.06 0.03 0.04 0.11 -0.18 0.13 0.02 -0.08 0.08 0.05
denial -0.08 1 -0.2 -0.68 0.62 -0.82 0.03 -0.13 -0.07 0.16 0.02 -0.06 -0.04 0.16 0.02
intern -0.18 -0.2 1 0.26 -0.05 0.45 0.06 -0.11 0.04 0.02 -0.06 0.08 0.04 0.02 0.01
biocentrism 0.09 -0.68* 0.26 1 -0.73 0.89 0.05 0.12 0.17 -0.35 -0.21 -0.02 -0.12 -0.29 -0.22
money -0.15 0.62* -0.05 -0.73* 1 -0.83 -0.1 -0.01 0 0.14 0.17 0.16 0.07 0.17 0.14
summotiv 0.06 -0.82* 0.45* 0.89* -0.83* 1 0.06 0.06 0.08 -0.22 -0.16 -0.02 -0.04 -0.22 -0.14
aesthetic 0.03 0.03 0.06* 0.05 -0.1 0.06 1 -0.46 -0.52 -0.24 0.01 -0.14 0.05 0.06 0.03
cogn 0.04 -0.13 -0.11 0.12 -0.01 0.06 -0.46* 1 -0.05 -0.42 -0.22 -0.06 -0.03 -0.17 -0.17
pract 0.11 -0.07 0.04 0.17 0 0.08 -0.52 -0.05 1 -0.29 -0.03 0.28 -0.15 -0.09 -0.08
progmat -0.18 0.16 0.02 -0.35 0.14 -0.22 -0.24 -0.42* -0.29* 1 0.23 -0.05 0.11 0.19 0.21
dverb 0.13 0.02 -0.06 -0.21 0.17 -0.16 0.01 -0.22 -0.03 0.23 1 0.51 0.42 0.55 0.81
indverb 0.02 -0.06 0.08 -0.02 0.16* -0.02 -0.14 -0.06 0.28 -0.05 0.51* 1 0.38 0.32 0.5
indph -0.08 -0.04 0.04 -0.12 0.07 -0.04 0.05 -0.03 -0.15 0.11 0.42* 0.38* 1 0.58 0.78
dph 0.08 0.16 0.02 -0.29 0.17 -0.22 0.06 -0.17 -0.09 0.19 0.55* 0.32* 0.58* 1 0.85
sumaggress 0.05 0.02 0.01 -0.22 0.14 -0.14 0.03 -0.17 -0.08 0.21 0.81* 0.5* 0.78* 0.85* 1
#корреляции для ведущей мотивации - когнитивная

p_values <- matrix(NA, nrow = ncol(clustercogn), ncol = ncol(clustercogn))
rownames(p_values) <- colnames(p_values) <- colnames(clustercogn)

for (i in 1:(ncol(clustercogn) - 1)) {
  for (j in (i + 1):ncol(clustercogn)) {
    cor_test_result <- cor.test(clustercogn[[i]], clustercogn[[j]])
    p_values[i, j] <- p_values[j, i] <- cor_test_result$p.value
  }
}

significant_level <- 0.05
significant <- ifelse(p_values < significant_level, "*", "")

cor_matrix_with_significance <- round(correlation_matrix, 2)
cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)] <- paste(cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)], significant[lower.tri(significant)], sep = "")

cor_clustercogn <- as.data.frame(cor_matrix_with_significance)
cor_clustercogn <- cor_clustercogn[-1, -1]
cor_clustercogn_html <- kable(cor_clustercogn, format = "html")
kable_styling(cor_clustercogn_html)
age denial intern biocentrism money summotiv aesthetic cogn pract progmat dverb indverb indph dph sumaggress
age 1 -0.08 -0.18 0.09 -0.15 0.06 0.03 0.04 0.11 -0.18 0.13 0.02 -0.08 0.08 0.05
denial -0.08 1 -0.2 -0.68 0.62 -0.82 0.03 -0.13 -0.07 0.16 0.02 -0.06 -0.04 0.16 0.02
intern -0.18 -0.2 1 0.26 -0.05 0.45 0.06 -0.11 0.04 0.02 -0.06 0.08 0.04 0.02 0.01
biocentrism 0.09 -0.68* 0.26 1 -0.73 0.89 0.05 0.12 0.17 -0.35 -0.21 -0.02 -0.12 -0.29 -0.22
money -0.15 0.62* -0.05 -0.73* 1 -0.83 -0.1 -0.01 0 0.14 0.17 0.16 0.07 0.17 0.14
summotiv 0.06 -0.82* 0.45* 0.89* -0.83* 1 0.06 0.06 0.08 -0.22 -0.16 -0.02 -0.04 -0.22 -0.14
aesthetic 0.03 0.03 0.06 0.05 -0.1 0.06 1 -0.46 -0.52 -0.24 0.01 -0.14 0.05 0.06 0.03
cogn 0.04 -0.13 -0.11 0.12 -0.01 0.06 -0.46 1 -0.05 -0.42 -0.22 -0.06 -0.03 -0.17 -0.17
pract 0.11 -0.07 0.04 0.17 0 0.08 -0.52* -0.05 1 -0.29 -0.03 0.28 -0.15 -0.09 -0.08
progmat -0.18 0.16 0.02 -0.35 0.14 -0.22 -0.24 -0.42* -0.29* 1 0.23 -0.05 0.11 0.19 0.21
dverb 0.13 0.02 -0.06 -0.21 0.17 -0.16 0.01 -0.22 -0.03 0.23* 1 0.51 0.42 0.55 0.81
indverb 0.02 -0.06* 0.08 -0.02 0.16 -0.02* -0.14 -0.06 0.28 -0.05 0.51* 1 0.38 0.32 0.5
indph -0.08 -0.04 0.04 -0.12 0.07 -0.04 0.05 -0.03 -0.15 0.11 0.42* 0.38 1 0.58 0.78
dph 0.08 0.16 0.02 -0.29* 0.17* -0.22* 0.06* -0.17 -0.09 0.19 0.55* 0.32 0.58* 1 0.85
sumaggress 0.05 0.02 0.01 -0.22 0.14 -0.14 0.03 -0.17 -0.08 0.21* 0.81* 0.5* 0.78* 0.85* 1
#корреляции для ведущей мотивации - практическая

p_values <- matrix(NA, nrow = ncol(clusterpract), ncol = ncol(clusterpract))
rownames(p_values) <- colnames(p_values) <- colnames(clusterpract)

for (i in 1:(ncol(clusterpract) - 1)) {
  for (j in (i + 1):ncol(clusterpract)) {
    cor_test_result <- cor.test(clusterpract[[i]], clusterpract[[j]])
    p_values[i, j] <- p_values[j, i] <- cor_test_result$p.value
  }
}

significant_level <- 0.05
significant <- ifelse(p_values < significant_level, "*", "")

cor_matrix_with_significance <- round(correlation_matrix, 2)
cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)] <- paste(cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)], significant[lower.tri(significant)], sep = "")

cor_clusterpract <- as.data.frame(cor_matrix_with_significance)
cor_clusterpract <- cor_clusterpract[-1, -1]
cor_clusterpract_html <- kable(cor_clusterpract, format = "html")
kable_styling(cor_clusterpract_html)
age denial intern biocentrism money summotiv aesthetic cogn pract progmat dverb indverb indph dph sumaggress
age 1 -0.08 -0.18 0.09 -0.15 0.06 0.03 0.04 0.11 -0.18 0.13 0.02 -0.08 0.08 0.05
denial -0.08 1 -0.2 -0.68 0.62 -0.82 0.03 -0.13 -0.07 0.16 0.02 -0.06 -0.04 0.16 0.02
intern -0.18* -0.2* 1 0.26 -0.05 0.45 0.06 -0.11 0.04 0.02 -0.06 0.08 0.04 0.02 0.01
biocentrism 0.09 -0.68* 0.26* 1 -0.73 0.89 0.05 0.12 0.17 -0.35 -0.21 -0.02 -0.12 -0.29 -0.22
money -0.15 0.62* -0.05 -0.73* 1 -0.83 -0.1 -0.01 0 0.14 0.17 0.16 0.07 0.17 0.14
summotiv 0.06 -0.82* 0.45* 0.89* -0.83* 1 0.06 0.06 0.08 -0.22 -0.16 -0.02 -0.04 -0.22 -0.14
aesthetic 0.03 0.03 0.06 0.05 -0.1 0.06 1 -0.46 -0.52 -0.24 0.01 -0.14 0.05 0.06 0.03
cogn 0.04 -0.13* -0.11 0.12 -0.01 0.06 -0.46* 1 -0.05 -0.42 -0.22 -0.06 -0.03 -0.17 -0.17
pract 0.11 -0.07 0.04 0.17 0 0.08 -0.52* -0.05 1 -0.29 -0.03 0.28 -0.15 -0.09 -0.08
progmat -0.18 0.16* 0.02 -0.35* 0.14 -0.22 -0.24* -0.42* -0.29 1 0.23 -0.05 0.11 0.19 0.21
dverb 0.13* 0.02 -0.06 -0.21 0.17 -0.16 0.01 -0.22 -0.03 0.23 1 0.51 0.42 0.55 0.81
indverb 0.02 -0.06 0.08 -0.02 0.16 -0.02 -0.14 -0.06 0.28 -0.05 0.51* 1 0.38 0.32 0.5
indph -0.08 -0.04 0.04 -0.12 0.07 -0.04 0.05 -0.03 -0.15 0.11 0.42* 0.38* 1 0.58 0.78
dph 0.08* 0.16 0.02 -0.29 0.17 -0.22 0.06 -0.17 -0.09 0.19 0.55* 0.32* 0.58* 1 0.85
sumaggress 0.05* 0.02 0.01 -0.22 0.14 -0.14 0.03 -0.17 -0.08 0.21 0.81* 0.5* 0.78* 0.85* 1
#корреляции для ведущей мотивации - прогматическая 

p_values <- matrix(NA, nrow = ncol(clusterprogmat), ncol = ncol(clusterprogmat))
rownames(p_values) <- colnames(p_values) <- colnames(clusterprogmat)

for (i in 1:(ncol(clusterprogmat) - 1)) {
  for (j in (i + 1):ncol(clusterprogmat)) {
    cor_test_result <- cor.test(clusterprogmat[[i]], clusterprogmat[[j]])
    p_values[i, j] <- p_values[j, i] <- cor_test_result$p.value
  }
}

significant_level <- 0.05
significant <- ifelse(p_values < significant_level, "*", "")

cor_matrix_with_significance <- round(correlation_matrix, 2)
cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)] <- paste(cor_matrix_with_significance[lower.tri(cor_matrix_with_significance)], significant[lower.tri(significant)], sep = "")

cor_clusterprogmat <- as.data.frame(cor_matrix_with_significance)
cor_clusterprogmat <- cor_clusterprogmat[-1, -1]
cor_clusterprogmat_html <- kable(cor_clusterprogmat, format = "html")
kable_styling(cor_clusterprogmat_html)
age denial intern biocentrism money summotiv aesthetic cogn pract progmat dverb indverb indph dph sumaggress
age 1 -0.08 -0.18 0.09 -0.15 0.06 0.03 0.04 0.11 -0.18 0.13 0.02 -0.08 0.08 0.05
denial -0.08 1 -0.2 -0.68 0.62 -0.82 0.03 -0.13 -0.07 0.16 0.02 -0.06 -0.04 0.16 0.02
intern -0.18 -0.2 1 0.26 -0.05 0.45 0.06 -0.11 0.04 0.02 -0.06 0.08 0.04 0.02 0.01
biocentrism 0.09* -0.68 0.26 1 -0.73 0.89 0.05 0.12 0.17 -0.35 -0.21 -0.02 -0.12 -0.29 -0.22
money -0.15* 0.62 -0.05 -0.73* 1 -0.83 -0.1 -0.01 0 0.14 0.17 0.16 0.07 0.17 0.14
summotiv 0.06* -0.82 0.45 0.89* -0.83* 1 0.06 0.06 0.08 -0.22 -0.16 -0.02 -0.04 -0.22 -0.14
aesthetic 0.03 0.03 0.06 0.05 -0.1 0.06 1 -0.46 -0.52 -0.24 0.01 -0.14 0.05 0.06 0.03
cogn 0.04 -0.13 -0.11 0.12 -0.01 0.06 -0.46 1 -0.05 -0.42 -0.22 -0.06 -0.03 -0.17 -0.17
pract 0.11 -0.07 0.04 0.17 0 0.08 -0.52* -0.05 1 -0.29 -0.03 0.28 -0.15 -0.09 -0.08
progmat -0.18 0.16 0.02 -0.35 0.14 -0.22 -0.24 -0.42 -0.29 1 0.23 -0.05 0.11 0.19 0.21
dverb 0.13 0.02 -0.06 -0.21 0.17 -0.16 0.01 -0.22 -0.03 0.23 1 0.51 0.42 0.55 0.81
indverb 0.02 -0.06 0.08 -0.02 0.16 -0.02 -0.14* -0.06 0.28 -0.05 0.51 1 0.38 0.32 0.5
indph -0.08 -0.04 0.04 -0.12 0.07 -0.04 0.05 -0.03 -0.15 0.11 0.42 0.38 1 0.58 0.78
dph 0.08 0.16 0.02 -0.29 0.17 -0.22 0.06 -0.17 -0.09 0.19 0.55 0.32 0.58 1 0.85
sumaggress 0.05 0.02 0.01 -0.22 0.14 -0.14 0.03 -0.17 -0.08 0.21* 0.81 0.5 0.78 0.85* 1

Дисперсия агрессивности и озабоченности эко проблемами

subset_data <- df[, c("sumaggress", "denial", "intern", "biocentrism", "money")]

melted_data <- melt(subset_data, id.vars = "sumaggress")

ggplot(melted_data, aes(x = variable, y = value)) +
  geom_boxplot(fill = 'skyblue', alpha = 0.7) +
  labs(title = "", x = "Озабоченность эко проблемами", y = "Общая агрессивность", fill = "Название группы") +
  theme_minimal() +
  #coord_cartesian(ylim = range(melted_data$value)) +
  scale_x_discrete(labels = c("Отрицание", "Интернальность", "Биоцентризм", "Деньги"))

Множественный дисперсионный анализ (MANOVA) (p < 0.1, если убираем money or intern)

manova_result <- manova(cbind(denial, intern, biocentrism, money) ~ sumaggress, data = df)

summary(manova_result)
##            Df  Pillai approx F num Df den Df Pr(>F)
## sumaggress  1 0.08294   1.7184      4     76 0.1546
## Residuals  79

Дисперсия агрессивности и мотивации взаимодействия

subset_data <- df[, c("sumaggress", "aesthetic", "cogn", "pract", "progmat")]
melted_data <- melt(subset_data, id.vars = "sumaggress")
ggplot(melted_data, aes(x = variable, y = value)) +
  geom_boxplot(fill = 'skyblue', alpha = 0.7) +
  labs(title = "", x = "Мотивация", y = "Общая агрессивность", fill = "Название группы") +
  theme_minimal() +
  #coord_cartesian(ylim = range(melted_data$value)) +
  scale_x_discrete(labels = c("Эстетическая", "Когнитивная", "Практическая", "Прагматическая"))

manova_result <- manova(cbind(aesthetic, cogn, pract) ~ sumaggress, data = df)

summary(manova_result)
##            Df   Pillai approx F num Df den Df Pr(>F)
## sumaggress  1 0.052348   1.4178      3     77  0.244
## Residuals  79

Поиск регрессионной модели без взаимодействия факторов

model <- lm(summotiv ~ indverb + indph + dverb + dph, data = df)
final_model <- step(model)
## Start:  AIC=444.78
## summotiv ~ indverb + indph + dverb + dph
## 
##           Df Sum of Sq   RSS    AIC
## - indverb  1     64.21 17427 443.08
## - dverb    1    131.68 17494 443.39
## - indph    1    152.90 17516 443.49
## <none>                 17363 444.78
## - dph      1    602.53 17965 445.54
## 
## Step:  AIC=443.08
## summotiv ~ indph + dverb + dph
## 
##         Df Sum of Sq   RSS    AIC
## - dverb  1     81.77 17509 441.46
## - indph  1    206.82 17634 442.03
## <none>               17427 443.08
## - dph    1    620.39 18047 443.91
## 
## Step:  AIC=441.46
## summotiv ~ indph + dph
## 
##         Df Sum of Sq   RSS    AIC
## - indph  1    174.63 17683 440.26
## <none>               17509 441.46
## - dph    1    998.52 18507 443.95
## 
## Step:  AIC=440.26
## summotiv ~ dph
## 
##        Df Sum of Sq   RSS    AIC
## <none>              17683 440.26
## - dph   1       861 18544 442.11
summary(final_model)    #везде очень маленький процент!
## 
## Call:
## lm(formula = summotiv ~ dph, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -32.745 -11.371  -1.119   7.255  40.629 
## 
## Coefficients:
##             Estimate Std. Error t value      Pr(>|t|)    
## (Intercept)  17.8746     2.7743   6.443 0.00000000849 ***
## dph          -1.6260     0.8291  -1.961        0.0534 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.96 on 79 degrees of freedom
## Multiple R-squared:  0.04643,    Adjusted R-squared:  0.03436 
## F-statistic: 3.847 on 1 and 79 DF,  p-value: 0.05337
model <- lm(sumaggress ~ denial + intern + biocentrism + money, data = df)
final_model <- step(model)
## Start:  AIC=272.07
## sumaggress ~ denial + intern + biocentrism + money
## 
##               Df Sum of Sq    RSS    AIC
## - money        1     0.029 2058.8 270.07
## - intern       1     7.940 2066.7 270.38
## <none>                     2058.7 272.07
## - denial       1    62.541 2121.3 272.49
## - biocentrism  1   127.961 2186.7 274.95
## 
## Step:  AIC=270.07
## sumaggress ~ denial + intern + biocentrism
## 
##               Df Sum of Sq    RSS    AIC
## - intern       1     8.149 2066.9 268.39
## <none>                     2058.8 270.07
## - denial       1    67.363 2126.1 270.68
## - biocentrism  1   184.691 2243.4 275.03
## 
## Step:  AIC=268.39
## sumaggress ~ denial + biocentrism
## 
##               Df Sum of Sq    RSS    AIC
## <none>                     2066.9 268.39
## - denial       1    69.395 2136.3 269.06
## - biocentrism  1   176.940 2243.8 273.04
summary(final_model)
## 
## Call:
## lm(formula = sumaggress ~ denial + biocentrism, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.9507 -3.4130 -0.0693  4.2276 10.7555 
## 
## Coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)  12.0783     1.0369  11.649 <0.0000000000000002 ***
## denial       -0.2938     0.1815  -1.618              0.1096    
## biocentrism  -0.4214     0.1631  -2.584              0.0116 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.148 on 78 degrees of freedom
## Multiple R-squared:  0.0793, Adjusted R-squared:  0.05569 
## F-statistic: 3.359 on 2 and 78 DF,  p-value: 0.03987
model <- lm(sumaggress ~ denial + intern + biocentrism + money + aesthetic + cogn + pract + progmat, data = df)
final_model <- step(model) #this one!
## Start:  AIC=275.7
## sumaggress ~ denial + intern + biocentrism + money + aesthetic + 
##     cogn + pract + progmat
## 
## 
## Step:  AIC=275.7
## sumaggress ~ denial + intern + biocentrism + money + aesthetic + 
##     cogn + pract
## 
##               Df Sum of Sq    RSS    AIC
## - intern       1     1.239 2000.8 273.75
## - money        1     2.563 2002.1 273.81
## - aesthetic    1     6.207 2005.7 273.95
## - pract        1    10.072 2009.6 274.11
## <none>                     1999.5 275.70
## - cogn         1    51.905 2051.4 275.78
## - biocentrism  1    64.774 2064.3 276.29
## - denial       1    68.093 2067.6 276.42
## 
## Step:  AIC=273.75
## sumaggress ~ denial + biocentrism + money + aesthetic + cogn + 
##     pract
## 
##               Df Sum of Sq    RSS    AIC
## - money        1     3.871 2004.6 271.91
## - aesthetic    1     6.645 2007.4 272.02
## - pract        1    10.870 2011.6 272.19
## <none>                     2000.8 273.75
## - cogn         1    57.420 2058.2 274.05
## - biocentrism  1    65.338 2066.1 274.36
## - denial       1    70.758 2071.5 274.57
## 
## Step:  AIC=271.91
## sumaggress ~ denial + biocentrism + aesthetic + cogn + pract
## 
##               Df Sum of Sq    RSS    AIC
## - aesthetic    1     6.010 2010.7 270.15
## - pract        1     8.946 2013.6 270.27
## <none>                     2004.6 271.91
## - cogn         1    54.206 2058.8 272.07
## - denial       1    66.894 2071.5 272.57
## - biocentrism  1   121.977 2126.6 274.69
## 
## Step:  AIC=270.15
## sumaggress ~ denial + biocentrism + cogn + pract
## 
##               Df Sum of Sq    RSS    AIC
## - pract        1     3.366 2014.0 268.29
## <none>                     2010.7 270.15
## - cogn         1    54.465 2065.1 270.32
## - denial       1    74.296 2084.9 271.09
## - biocentrism  1   154.310 2165.0 274.14
## 
## Step:  AIC=268.29
## sumaggress ~ denial + biocentrism + cogn
## 
##               Df Sum of Sq    RSS    AIC
## <none>                     2014.0 268.29
## - cogn         1    52.888 2066.9 268.39
## - denial       1    76.576 2090.6 269.31
## - biocentrism  1   167.272 2181.3 272.75
summary(final_model)
## 
## Call:
## lm(formula = sumaggress ~ denial + biocentrism + cogn, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.3943 -3.6821 -0.1635  3.8742 10.5538 
## 
## Coefficients:
##             Estimate Std. Error t value       Pr(>|t|)    
## (Intercept)  14.4664     1.9701   7.343 0.000000000185 ***
## denial       -0.3092     0.1807  -1.711         0.0911 .  
## biocentrism  -0.4103     0.1622  -2.529         0.0135 *  
## cogn         -0.7427     0.5223  -1.422         0.1591    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.114 on 77 degrees of freedom
## Multiple R-squared:  0.1029, Adjusted R-squared:  0.0679 
## F-statistic: 2.943 on 3 and 77 DF,  p-value: 0.03824
model <- lm(summotiv ~ indverb + indph + dverb + dph + aesthetic + cogn + pract + progmat, data = df)
final_model <- step(model)
## Start:  AIC=448.08
## summotiv ~ indverb + indph + dverb + dph + aesthetic + cogn + 
##     pract + progmat
## 
## 
## Step:  AIC=448.08
## summotiv ~ indverb + indph + dverb + dph + aesthetic + cogn + 
##     pract
## 
##             Df Sum of Sq   RSS    AIC
## - indverb    1      4.44 16799 446.11
## - dverb      1     43.67 16839 446.30
## - indph      1    192.46 16987 447.01
## - cogn       1    193.82 16989 447.01
## - pract      1    410.07 17205 448.04
## <none>                   16795 448.08
## - aesthetic  1    491.94 17287 448.42
## - dph        1    561.13 17356 448.75
## 
## Step:  AIC=446.11
## summotiv ~ indph + dverb + dph + aesthetic + cogn + pract
## 
##             Df Sum of Sq   RSS    AIC
## - dverb      1     39.77 16839 444.30
## - cogn       1    201.69 17001 445.07
## - indph      1    224.50 17024 445.18
## <none>                   16799 446.11
## - aesthetic  1    502.98 17302 446.50
## - pract      1    508.23 17308 446.52
## - dph        1    564.46 17364 446.78
## 
## Step:  AIC=444.3
## summotiv ~ indph + dph + aesthetic + cogn + pract
## 
##             Df Sum of Sq   RSS    AIC
## - indph      1    200.00 17039 443.25
## - cogn       1    250.96 17090 443.50
## <none>                   16839 444.30
## - pract      1    523.33 17362 444.78
## - aesthetic  1    547.15 17386 444.89
## - dph        1    808.24 17647 446.10
## 
## Step:  AIC=443.25
## summotiv ~ dph + aesthetic + cogn + pract
## 
##             Df Sum of Sq   RSS    AIC
## - cogn       1    280.24 17319 442.58
## <none>                   17039 443.25
## - pract      1    469.78 17509 443.46
## - aesthetic  1    547.12 17586 443.81
## - dph        1    614.89 17654 444.13
## 
## Step:  AIC=442.58
## summotiv ~ dph + aesthetic + pract
## 
##             Df Sum of Sq   RSS    AIC
## - pract      1    268.50 17588 441.82
## - aesthetic  1    282.95 17602 441.89
## <none>                   17319 442.58
## - dph        1    823.31 18143 444.34
## 
## Step:  AIC=441.82
## summotiv ~ dph + aesthetic
## 
##             Df Sum of Sq   RSS    AIC
## - aesthetic  1     95.40 17683 440.26
## <none>                   17588 441.82
## - dph        1    891.12 18479 443.82
## 
## Step:  AIC=440.26
## summotiv ~ dph
## 
##        Df Sum of Sq   RSS    AIC
## <none>              17683 440.26
## - dph   1       861 18544 442.11
summary(final_model)
## 
## Call:
## lm(formula = summotiv ~ dph, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -32.745 -11.371  -1.119   7.255  40.629 
## 
## Coefficients:
##             Estimate Std. Error t value      Pr(>|t|)    
## (Intercept)  17.8746     2.7743   6.443 0.00000000849 ***
## dph          -1.6260     0.8291  -1.961        0.0534 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.96 on 79 degrees of freedom
## Multiple R-squared:  0.04643,    Adjusted R-squared:  0.03436 
## F-statistic: 3.847 on 1 and 79 DF,  p-value: 0.05337

Средние и стандартные отклонения для мотивации взаимодействия и агрессивности

summary_df <- data.frame(
  Variable = c("Эстетическая", "Когнитивная", "Практическая", "Прагматическая"),
  Mean = c(mean(df$aesthetic), mean(df$cogn), mean(df$pract), mean(df$progmat)),
  SD = c(sd(df$aesthetic), sd(df$cogn), sd(df$pract), sd(df$progmat))
)

ggplot(summary_df, aes(x = Variable, y = Mean)) +
  geom_bar(stat = "identity", fill = "skyblue", alpha = 0.7) +
  geom_errorbar(aes(ymin = Mean - SD, ymax = Mean + SD), width = 0.2, color = "black") +
  geom_text(aes(label = round(Mean, 2)), vjust = -0.5, size = 3, color = "black") +
  labs(x = "Мотивация взаимодействия с природой", y = "Среднее", title = "") +
  theme_minimal() +
  labs(fill = NULL) 

summary_df <- data.frame(
  Variable = c("Прямая физическая", "Прямая вербальная", "Косвенная физическая", "Косвенная вербальная"),
  Mean = c(mean(df$indph), mean(df$indverb), mean(df$dph), mean(df$dverb)),
  SD = c(sd(df$indph), sd(df$indverb), sd(df$dph), sd(df$dverb))
)

ggplot(summary_df, aes(x = Variable, y = Mean)) +
  geom_bar(stat = "identity", fill = "skyblue", alpha = 0.7) +
  geom_errorbar(aes(ymin = Mean - SD, ymax = Mean + SD), width = 0.2, color = "black") +
  geom_text(aes(label = round(Mean, 2)), vjust = -0.5, size = 3, color = "black") +
  labs(x = "Агрессивность", y = "Среднее", title = "") +
  theme_minimal() +
  labs(fill = NULL) 

Средние и доверительные интервалы для мотивации взаимодействия и агрессивности

data <- data.frame(
  Variable = c("Эстетическая", "Когнитивная", "Практическая", "Прагматическая"),
  Mean = c(mean(df$aesthetic), mean(df$cogn), mean(df$pract), mean(df$progmat)),
  SD = c(sd(df$aesthetic), sd(df$cogn), sd(df$pract), sd(df$progmat))
)
# Расчет доверительных интервалов
data$CI_lower <- data$Mean - qt(0.975, df = length(df$aesthetic) - 1) * (data$SD / sqrt(length(df$aesthetic)))
data$CI_upper <- data$Mean + qt(0.975, df = length(df$aesthetic) - 1) * (data$SD / sqrt(length(df$aesthetic)))

ggplot(data, aes(x = Variable, y = Mean)) +
  geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
  geom_bar(stat = "identity", fill = "skyblue", width = 0.5, alpha = 0.7) +
  geom_text(aes(label = round(Mean, 2)), vjust = -0.5, size = 3, color = "black") +
  labs(x = "Мотивация взаимодейтсвия с природой", y = "Среднее", title = "") +
  theme_minimal() +
  labs(fill = NULL)

data <- data.frame(
  Variable = c("Прямая физическая", "Прямая вербальная", "Косвенная физическая", "Косвенная вербальная"),
  Mean = c(mean(df$indph), mean(df$indverb), mean(df$dph), mean(df$dverb)),
  SD = c(sd(df$indph), sd(df$indverb), sd(df$dph), sd(df$dverb))
)

data$CI_lower <- data$Mean - qt(0.975, df = length(df$indph) - 1) * (data$SD / sqrt(length(df$indph)))
data$CI_upper <- data$Mean + qt(0.975, df = length(df$indph) - 1) * (data$SD / sqrt(length(df$indph)))

ggplot(data, aes(x = Variable, y = Mean)) +
  geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
  geom_bar(stat = "identity", fill = "skyblue", width = 0.5, alpha = 0.7) +
  geom_text(aes(label = round(Mean, 2)), vjust = -0.5, size = 3, color = "black") +
  labs(x = "Агрессивность", y = "Среднее", title = "") +
  theme_minimal() +
  labs(fill = NULL) 

Гистограммы

hist_data <- data.frame(
  Variable = rep(c("aesthetic", "cogn", "pract", "progmat"), each = length(df$aesthetic)),
  Value = c(df$aesthetic, df$cogn, df$pract, df$progmat)
)

ggplot(hist_data, aes(x = Value)) +
  geom_histogram(binwidth = 1, position = "identity", alpha = 0.7, fill = "skyblue") +
  facet_wrap(~ Variable, scales = "free", labeller = labeller(Variable = c(aesthetic = "Эстетическая", cogn = "Когнитивная", pract = "Практическая", progmat = "Прагматическая"))) +
  labs(x = "Значения", y = "Частота", fill = NULL) +
  coord_cartesian(ylim = c(0, 15)) +  # Фиксируем диапазон значений по оси y
  theme_minimal() +
  theme_light()

hist_data <- data.frame(
  Variable = rep(c("dph", "indph", "indverb", "dverb"), each = length(df$dph)),
  Value = c(df$dph, df$indph, df$dverb, df$indverb)
)

ggplot(hist_data, aes(x = Value)) +
  geom_histogram(binwidth = 1, position = "identity", alpha = 0.7, fill = "skyblue") +
  facet_wrap(~ Variable, scales = "free", labeller = labeller(Variable = c(dph = "Прямая физическа",
                                                                           indph = "Косвенная физическая", 
                                                                           indverb = "Косвеная вербальная", 
                                                                           dverb = "Прямая вербальная"))) +
  
  labs(x = "Значения", y = "Частота", fill = NULL) +
  coord_cartesian(ylim = c(0, 25)) +  
  theme_minimal() +
  theme_light()

hist_data <- data.frame(
  Variable = rep(c("denial", "intern", "money", "biocentrism"), each = length(df$denial)),
  Value = c(df$denial, df$intern, df$money, df$biocentrism)
)

ggplot(hist_data, aes(x = Value)) +
  geom_histogram(binwidth = 1, position = "identity", alpha = 0.7, fill = "skyblue") +
  facet_wrap(~ Variable, scales = "free", labeller = labeller(Variable = c(denial = "Отрицание", intern = "Интернальность", money = "Деньги", biocentrism = "Биоцентризм"))) +
  labs(x = "Значения", y = "Частота", fill = NULL) +
  coord_cartesian(ylim = c(0, 15)) +  # Фиксируем диапазон значений по оси y
  theme_minimal() +
  theme_light()

hist_values <- hist(df$summotiv, plot = FALSE)
barplot(hist_values$counts, col = "skyblue", border = "white", 
        main = "", xlab = "Озабоченность эко проблемами", ylab = "Частота", space = 0)
axis(1, at = seq_along(hist_values$breaks), labels = hist_values$breaks)

Ящики с усами

par(mfrow = c(1, 4))
ylim <- range(df$denial, df$intern, df$money, df$biocentrism)
boxplot(df$denial, main = "Denial", ylim = ylim)
boxplot(df$intern, main = "Internalism", ylim = ylim)
boxplot(df$money, main = "Money", ylim = ylim)
boxplot(df$biocentrism, main = "Biocentrism", ylim = ylim)

par(mfrow = c(1, 4))
ylim <- range(c(df$aesthetic, df$cogn, df$pract, df$progmat))
boxplot(df$aesthetic, main = "aesthetic", ylim = ylim)
boxplot(df$cogn, main = "cognitive", ylim = ylim)
boxplot(df$pract, main = "practical", ylim = ylim)
boxplot(df$progmat, main = "pragmatic", ylim = ylim)

par(mfrow = c(1, 4))
ylim <- range(c(df$dverb, df$indverb, df$dph, df$indph))
boxplot(df$dverb, main = "dverb", ylim = ylim)
boxplot(df$indverb, main = "indverb", ylim = ylim)
boxplot(df$dph, main = "dph", ylim = ylim)
boxplot(df$indph, main = "indph", ylim = ylim)

Regression for environmental concerns and aggression

# Plot scatterplot
plot(df$sumaggress, df$money, 
     main="Scatterplot with Regression Line", 
     xlab="Money", ylab="Aggression", pch=19)
  
# Linear regression and coefficients
model <- lm(sumaggress ~ money, data = df)
coefficients <- coef(model)
  
# Add regression line
abline(model, col="red")

# Output regression coefficients
print(coefficients)
## (Intercept)       money 
##  10.1495565   0.1274826
plot(df$sumaggress, df$denial, 
     main="Scatterplot with Regression Line", 
     xlab="Denial", ylab="Aggression", pch=19)
  
model <- lm(sumaggress ~ denial, data = df)
coefficients <- coef(model)
  
abline(model, col="red")

print(coefficients)
## (Intercept)      denial 
##  9.86158835  0.02669637
plot(df$sumaggress, df$intern, 
     main="Scatterplot with Regression Line", 
     xlab="Internality", ylab="Aggression", pch=19)
  
model <- lm(sumaggress ~ intern, data = df)
coefficients <- coef(model)
  
abline(model, col="red")

print(coefficients)
## (Intercept)      intern 
## 9.800814637 0.009949252
plot(df$sumaggress, df$biocentrism, 
     main="", 
     xlab="Биоцентризм", ylab="Агрессивность", pch=19)
  
model <- lm(sumaggress ~biocentrism , data = df)
coefficients <- coef(model)
  
abline(model, col="red")

print(coefficients)
## (Intercept) biocentrism 
##  11.2595368  -0.2411373
ggplot(df, aes(x = biocentrism, y = sumaggress)) + 
  geom_point()  + 
  geom_smooth(method = 'lm') + 
  labs(x = 'Биоцентризм', y = 'Агрессивность') +
  theme_minimal() +
  theme_light()
## `geom_smooth()` using formula = 'y ~ x'

final regression model

model <- lm(sumaggress ~ aesthetic + cogn + pract + progmat + biocentrism + denial + money + intern, data = df)
final_model <- step(model)  
## Start:  AIC=275.7
## sumaggress ~ aesthetic + cogn + pract + progmat + biocentrism + 
##     denial + money + intern
## 
## 
## Step:  AIC=275.7
## sumaggress ~ aesthetic + cogn + pract + biocentrism + denial + 
##     money + intern
## 
##               Df Sum of Sq    RSS    AIC
## - intern       1     1.239 2000.8 273.75
## - money        1     2.563 2002.1 273.81
## - aesthetic    1     6.207 2005.7 273.95
## - pract        1    10.072 2009.6 274.11
## <none>                     1999.5 275.70
## - cogn         1    51.905 2051.4 275.78
## - biocentrism  1    64.774 2064.3 276.29
## - denial       1    68.093 2067.6 276.42
## 
## Step:  AIC=273.75
## sumaggress ~ aesthetic + cogn + pract + biocentrism + denial + 
##     money
## 
##               Df Sum of Sq    RSS    AIC
## - money        1     3.871 2004.6 271.91
## - aesthetic    1     6.645 2007.4 272.02
## - pract        1    10.870 2011.6 272.19
## <none>                     2000.8 273.75
## - cogn         1    57.420 2058.2 274.05
## - biocentrism  1    65.338 2066.1 274.36
## - denial       1    70.758 2071.5 274.57
## 
## Step:  AIC=271.91
## sumaggress ~ aesthetic + cogn + pract + biocentrism + denial
## 
##               Df Sum of Sq    RSS    AIC
## - aesthetic    1     6.010 2010.7 270.15
## - pract        1     8.946 2013.6 270.27
## <none>                     2004.6 271.91
## - cogn         1    54.206 2058.8 272.07
## - denial       1    66.894 2071.5 272.57
## - biocentrism  1   121.977 2126.6 274.69
## 
## Step:  AIC=270.15
## sumaggress ~ cogn + pract + biocentrism + denial
## 
##               Df Sum of Sq    RSS    AIC
## - pract        1     3.366 2014.0 268.29
## <none>                     2010.7 270.15
## - cogn         1    54.465 2065.1 270.32
## - denial       1    74.296 2084.9 271.09
## - biocentrism  1   154.310 2165.0 274.14
## 
## Step:  AIC=268.29
## sumaggress ~ cogn + biocentrism + denial
## 
##               Df Sum of Sq    RSS    AIC
## <none>                     2014.0 268.29
## - cogn         1    52.888 2066.9 268.39
## - denial       1    76.576 2090.6 269.31
## - biocentrism  1   167.272 2181.3 272.75
summary(final_model)
## 
## Call:
## lm(formula = sumaggress ~ cogn + biocentrism + denial, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.3943 -3.6821 -0.1635  3.8742 10.5538 
## 
## Coefficients:
##             Estimate Std. Error t value       Pr(>|t|)    
## (Intercept)  14.4664     1.9701   7.343 0.000000000185 ***
## cogn         -0.7427     0.5223  -1.422         0.1591    
## biocentrism  -0.4103     0.1622  -2.529         0.0135 *  
## denial       -0.3092     0.1807  -1.711         0.0911 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.114 on 77 degrees of freedom
## Multiple R-squared:  0.1029, Adjusted R-squared:  0.0679 
## F-statistic: 2.943 on 3 and 77 DF,  p-value: 0.03824

boxplots for aggression across motivation

df <- read.csv('file2.csv')
df_full <- read.csv('file3 (2).csv')

df$age[is.na(df$age)] <- mean(df$age, na.rm = TRUE)  
df$sex <- ifelse(df$sex == "m", 0, 1)

df_full <- df_full %>%
  pivot_longer(cols = c("indverb", "dverb", "dph", "indph"), names_to = "variable") %>%
  pivot_longer(cols = c('cluster_aesthetic', 'cluster_cogn', 'cluster_progmat', 'cluster_pract'), names_to = "cluster", values_to = "cluster_value") %>%
  filter(cluster_value == 1) %>%
  mutate(variable_cluster = ifelse(cluster == "cluster_aesthetic", "cluster_aesthetic",
                                    ifelse(cluster == "cluster_cogn", "cluster_cogn",
                                           ifelse(cluster == "cluster_progmat", "cluster_progmat", "cluster_pract"))))

# Определяем порядок переменных на оси x
x_order <- c('cluster_aesthetic', 'cluster_cogn', 'cluster_progmat', 'cluster_pract')

ggplot(df_full, aes(x = variable_cluster, y = value, fill = variable)) +
  geom_boxplot() +
  scale_x_discrete(limits = x_order, labels = c('cluster_aesthetic' = 'Эстетическая', 
                                                'cluster_cogn' = 'Когнитивная', 
                                                'cluster_progmat' = 'Прагматичекая', 
                                                'cluster_pract' = 'Практическая')) +
  ylab("Значение") +
  xlab('Тип мотивации')+
  theme_minimal() +
  #theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  labs(title = NULL) + 
  scale_fill_manual(name = "Агрессивность",  
                    values = c("indverb" = "#F8766D", 
                               "dverb" = "#00BA38", 
                               "dph" = "#619CFF", 
                               "indph" = "#FF61C0"),
                    labels = c("indverb" = "Косвенная вербальная", 
                               "dverb" = "Прямая вербальная", 
                               "dph" = "Прямая физическая", 
                               "indph" = "Непрямая физическая"))

boxplots for env concern across motivation

df <- read.csv('file2.csv')
df_full <- read.csv('file3 (2).csv')

df$age[is.na(df$age)] <- mean(df$age, na.rm = TRUE)  
df$sex <- ifelse(df$sex == "m", 0, 1)

df_full <- df_full %>%
  pivot_longer(cols = c("denial", "intern", "biocentrism", "money"), names_to = "variable") %>%
  pivot_longer(cols = c('cluster_aesthetic', 'cluster_cogn', 'cluster_progmat', 'cluster_pract'), names_to = "cluster", values_to = "cluster_value") %>%
  filter(cluster_value == 1) %>%
  mutate(variable_cluster = ifelse(cluster == "cluster_aesthetic", "cluster_aesthetic",
                                    ifelse(cluster == "cluster_cogn", "cluster_cogn",
                                           ifelse(cluster == "cluster_progmat", "cluster_progmat", "cluster_pract"))))

# Определяем порядок переменных на оси x
x_order <- c('cluster_aesthetic', 'cluster_cogn', 'cluster_progmat', 'cluster_pract')

ggplot(df_full, aes(x = variable_cluster, y = value, fill = variable)) +
  geom_boxplot() +
  scale_x_discrete(limits = x_order, labels = c('cluster_aesthetic' = 'Эстетическая', 
                                                'cluster_cogn' = 'Когнитивная', 
                                                'cluster_progmat' = 'Прагматичекая', 
                                                'cluster_pract' = 'Практическая')) +
  ylab("Значение") +
  xlab('Тип мотивации')+
  theme_minimal() +
  #theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  labs(title = NULL) + 
  scale_fill_manual(name = "Озабоченность",  
                    values = c("denial" = "#F8766D", 
                               "intern" = "#00BA38", 
                               "biocentrism" = "#619CFF", 
                               "money" = "#FF61C0"),
                    labels = c('denial' = 'Отрицание', 
                               'intern' = 'Интернальность', 
                               'biocentrism' = 'Биоцентризм', 
                               'money' = 'Деньги'))