library(tidyverse)
library(janitor)

survey <- read.csv("Cleaned_Truth_of_fast_fashion.csv", stringsAsFactors = FALSE)

survey <- survey %>%
  clean_names()

head(survey)
##   brand_willing purchase_brand purchase_frequency thrift_frequency
## 1           All            H&M                  2                3
## 2        Uniqlo         Uniqlo                  2                3
## 3          None           None                  1                1
## 4           All            H&M                  2                4
## 5           All            H&M                  3                1
## 6           H&M            H&M                  3                3
##   trend_opinion labor_concern
## 1             3             3
## 2             1             4
## 3             1             1
## 4             1             5
## 5             3             4
## 6             3             1
summary(survey)
##  brand_willing      purchase_brand     purchase_frequency thrift_frequency
##  Length:17          Length:17          Min.   :1.000      Min.   :1.000   
##  Class :character   Class :character   1st Qu.:2.000      1st Qu.:2.000   
##  Mode  :character   Mode  :character   Median :2.000      Median :3.000   
##                                        Mean   :2.294      Mean   :2.412   
##                                        3rd Qu.:3.000      3rd Qu.:3.000   
##                                        Max.   :3.000      Max.   :4.000   
##  trend_opinion   labor_concern  
##  Min.   :1.000   Min.   :1.000  
##  1st Qu.:2.000   1st Qu.:2.000  
##  Median :2.000   Median :3.000  
##  Mean   :2.412   Mean   :3.235  
##  3rd Qu.:3.000   3rd Qu.:4.000  
##  Max.   :5.000   Max.   :5.000
survey$purchase_frequency <- as.numeric(survey$purchase_frequency)
survey$labor_concern <- as.numeric(survey$labor_concern)
survey$thrift_frequency <- as.numeric(survey$thrift_frequency)

model <- lm(purchase_frequency ~ labor_concern, data = survey)

summary(model)
## 
## Call:
## lm(formula = purchase_frequency ~ labor_concern, data = survey)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.3087 -0.2957 -0.2826  0.6978  0.7109 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    2.315217   0.405272   5.713 4.11e-05 ***
## labor_concern -0.006522   0.116706  -0.056    0.956    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6071 on 15 degrees of freedom
## Multiple R-squared:  0.0002081,  Adjusted R-squared:  -0.06644 
## F-statistic: 0.003123 on 1 and 15 DF,  p-value: 0.9562
ggplot(survey, aes(x = labor_concern, y = purchase_frequency)) +
  geom_point(color = "blue") +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(
    title = "Relationship Between Labor Concern and Purchase Frequency",
    x = "Labor Concern (1 = Low, 5 = High)",
    y = "Purchase Frequency (1 = Never, 5 = Often)"
  ) +
  theme_minimal()

model2 <- lm(purchase_frequency ~ labor_concern + thrift_frequency, data = survey)

summary(model2)
## 
## Call:
## lm(formula = purchase_frequency ~ labor_concern + thrift_frequency, 
##     data = survey)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.3097 -0.2949 -0.2836  0.6989  0.7102 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       2.317182   0.499672   4.637 0.000384 ***
## labor_concern    -0.006243   0.126812  -0.049 0.961434    
## thrift_frequency -0.001189   0.164311  -0.007 0.994328    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6284 on 14 degrees of freedom
## Multiple R-squared:  0.0002119,  Adjusted R-squared:  -0.1426 
## F-statistic: 0.001483 on 2 and 14 DF,  p-value: 0.9985