library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag():    dplyr, stats
library(prcr)

df <- read_csv("~/Downloads/lassi with reversing.csv")
## Parsed with column specification:
## cols(
##   .default = col_integer(),
##   group = col_character(),
##   teacher = col_character(),
##   mnth = col_character(),
##   type = col_character(),
##   subj = col_character(),
##   time = col_character(),
##   Las_CON = col_double(),
##   Las_TST = col_double(),
##   Las_TMT = col_double(),
##   Las_ATT = col_double(),
##   Las_STA = col_double(),
##   Las_MOT = col_double()
## )
## See spec(...) for full column specifications.
df <- select(df,
             LAS_CON = Las_CON,
             LAS_TST = Las_TST,
             LAS_TMT = Las_TMT,
             LAS_ATT = Las_ATT,
             LAS_STA = Las_STA,
             LAS_MOT = Las_MOT)

# plot_r_squared(df, LAS_CON, LAS_TST, LAS_TMT, LAS_ATT, LAS_STA, LAS_MOT, r_squared_table=T)

# p3 <- create_profiles(df, LAS_CON, LAS_TST, LAS_TMT, LAS_ATT, LAS_STA, LAS_MOT, n_profiles = 3, to_center = T, to_scale = T)
# 
# plot(p3)

p4 <- create_profiles(df, LAS_CON, LAS_TST, LAS_TMT, LAS_ATT, LAS_STA, LAS_MOT, n_profiles = 4, to_center = T, to_scale = T)
## Prepared data: Removed 0 incomplete cases
## Hierarchical clustering carried out on: 299 cases
## Clustered data: Using a 4 cluster solution
## Calculated statistics: R-squared = 0.529
plot(p4)

p5 <- create_profiles(df, LAS_CON, LAS_TST, LAS_TMT, LAS_ATT, LAS_STA, LAS_MOT, n_profiles = 5, to_center = T, to_scale = T)
## Prepared data: Removed 0 incomplete cases
## Hierarchical clustering carried out on: 299 cases
## Clustered data: Using a 5 cluster solution
## Calculated statistics: R-squared = 0.562
plot(p5)

# p6 <- create_profiles(df, LAS_CON, LAS_TST, LAS_TMT, LAS_ATT, LAS_STA, LAS_MOT, n_profiles = 6, to_center = T, to_scale = T)
# 
# plot(p6)