Row

Which of these factors are statistically significant for Pressure Perception of Students?

Row

Pressure Perception Distribution

Pressure Group Classification

Row

Daily Average Screen Time

Daily Average Screen Time Between Groups

Row

Daily Average Physical & Social Activity Time

Daily Average Physical & Social Activity Time Between Groups

Row

Predictors of Schoolwork Pressure: A Logistic Regression Analysis

Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.5786618 0.9503024 2.7135172 0.0066573
Mean_daily_screen_time 0.0606545 0.0338297 1.7929354 0.0729833
Mean_daily_Physical_and_Social_Activity -0.1485218 0.0513876 -2.8902252 0.0038497
Home_Occupants -0.1418291 0.1153783 -1.2292532 0.2189769
Avg_Night_Sleep -0.0036840 0.0965294 -0.0381645 0.9695566
---
title: "Student Pressure Perception Analysis"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    theme: flatly
    social: menu
    source_code: embed
---


```{r setup, include=FALSE}
# Load required libraries
library(flexdashboard)
library(ggplot2)
library(tidyverse)
library(patchwork)
library(RColorBrewer)
library(igraph)
library(plotly)
library(shiny)

# Load and prepare data
df_imputed <- read.csv("df_imputed.csv")
df_imputed$Schoolwork_Pressure <- factor(df_imputed$Schoolwork_Pressure, 
                                        levels = c("None", "Very little", "Some", "A lot"))

df_imputed <- df_imputed %>%
  mutate(
    Pressure_Group = case_when(
      Schoolwork_Pressure %in% c("None", "Very little") ~ "Low Pressure",
      Schoolwork_Pressure %in% c("Some", "A lot") ~ "High Pressure"
    ),
    Schoolwork_Pressure_Binary = factor(Schoolwork_Pressure_Binary, 
                                       levels = c("Low Pressure", "High Pressure"))
  )

# Set color palette
pressure_colors <- c("Low Pressure" = "#6baed6", "High Pressure" = "#756bb1")
activity_colors <- c("#238b45", "#74c476")
```


Column {.sidebar}
-----------------------------------------------------------------------
- This dashboard explores how students perceive academic pressure and its relationship with their daily habits.

<br> 

- Built from student survey data, it reveals key behavioral trends that correlate with academic stress perception.

<br>

- Educators and parents can use these insights to identify at-risk patterns and promote balanced student lifestyles.

<br><br>  

___Why it matters is that early detection of stress factors can help improve student well-being and academic performance___




Row {data-height=375}
-----------------------------------------------------------------------

```{r}

# Create nodes data frame
nodes <- data.frame(
  id = c("center", "screen_time", "activity", "home_occupants", "sleep"),
  label = c("Perception on\nSchool Work Pressure", 
            "Mean Daily\nScreen Time", 
            "Mean Daily\nPhysical &\nSocial Activity",
            "Home \nOccupants", 
            "Average \nNight Sleep"),
  x = c(0, -2, 2, -2, 2),
  y = c(0, 2, 2, -2, -2),
  size = c(120, 120, 120, 120, 120)
)

# Create edges data frame (connections between nodes)
edges <- data.frame(
  from = c("screen_time", "activity", "home_occupants", "sleep"),
  to = rep("center", 4),
  arrow.size = 4
)

# Create the graph
g <- graph_from_data_frame(edges, vertices = nodes, directed = TRUE)

# Plot the graph
plot(g, 
     layout = as.matrix(nodes[, c("x", "y")]),
     vertex.label = nodes$label,
     vertex.size = nodes$size,
     vertex.color = c("darkseagreen3", rep("gold2", 5)),
     vertex.frame.color = "gray",
     vertex.label.color = "black",
     vertex.label.cex = 1,
     edge.arrow.size = 0.5,
     edge.arrow.width = 1,
     edge.color = "red4")


```



```{r}

valueBox(tags$div(style = "font-size: 28px; font-weight: bold;", 
           "Which of these factors are statistically significant for Pressure Perception of Students?"),
  caption = tags$div(style = "font-size: 18px;", "Analysis of Key Predictors"), 
  icon = icon("question-circle", "fa-3x"),
  color = "warning"
)
```










Row
-------------------------------------


### Pressure Perception Distribution

```{r,echo=FALSE, message=FALSE, warning=FALSE}

ggplot(df_imputed, aes(x = Schoolwork_Pressure, fill = Pressure_Group)) +
  geom_bar(color = "black", alpha = 0.8) +
  scale_fill_manual(values = pressure_colors) +
  theme_minimal(base_size = 14) +
  labs(
    subtitle = "Breakdown of students",
    x = "Pressure Level", 
    y = "Number of Students",
    fill = "Pressure Group"
  ) +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1, size = 12),
    plot.title = element_text(size = 18, face = "bold", hjust = 0.5),
    plot.subtitle = element_text(size = 12, hjust = 0.5, color = "gray40"),
    legend.position = "bottom"
  ) +
  guides(fill = guide_legend(title.position = "top"))

```


### Pressure Group Classification

```{r,echo=FALSE, message=FALSE, warning=FALSE}

ggplot(df_imputed, aes(x = Schoolwork_Pressure_Binary, fill = Schoolwork_Pressure_Binary)) +
  geom_bar(color = "black", alpha = 0.8, show.legend = FALSE) +
  scale_fill_manual(values = pressure_colors) +
  theme_minimal(base_size = 14) +
   labs(
    subtitle = "Students grouped into high/low pressure categories",
    x = "Pressure Category", 
    y = "Number of Students"
  ) +
  theme(
    plot.title = element_text(size = 18, face = "bold", hjust = 0.5),
    plot.subtitle = element_text(size = 12, hjust = 0.5, color = "gray40"),
    axis.text.x = element_text(size = 12)
  ) +
  geom_text(stat = 'count', aes(label = ..count..), vjust = 1.5, size = 5)




```



Row
-----------------------------------------------------------------------

### Daily Average Screen Time

```{r,echo=FALSE, message=FALSE, warning=FALSE}
ggplot(df_imputed, aes(x = Mean_daily_screen_time)) +
  geom_density(fill = activity_colors[1], alpha = 0.6, color = NA) +
  theme_minimal(base_size = 14) +
  labs(
    x = "Daily Average Screen Time (hours)", 
    y = "Density"
  ) +
  theme(
    plot.title = element_text(size = 16, face = "bold")
  )
```


### Daily Average Screen Time Between Groups



```{r,echo=FALSE, message=FALSE, warning=FALSE}

ggplot(df_imputed, aes(x = Schoolwork_Pressure_Binary, y = Mean_daily_screen_time, 
                      fill = Schoolwork_Pressure_Binary)) +
  geom_boxplot(alpha = 0.8, show.legend = FALSE) +
  scale_fill_manual(values = pressure_colors) +
  theme_minimal(base_size = 14) +
  labs(
    x = "Pressure Group", 
    y = "Daily Average Screen Time (hours)"
  ) +
  theme(
    plot.title = element_text(size = 16, face = "bold")
  )



```




Row
-----------------------------------------------------------------------

### Daily Average Physical & Social Activity Time

```{r,echo=FALSE, message=FALSE, warning=FALSE}
ggplot(df_imputed, aes(x = Mean_daily_Physical_and_Social_Activity)) +
  geom_density(fill = activity_colors[2], alpha = 0.6, color = NA) +
  theme_minimal(base_size = 14) +
  labs(
    x = "Daily Average Physical & Social Activity Time", 
    y = "Density"
  ) +
  theme(
    plot.title = element_text(size = 16, face = "bold")
  )

```


### Daily Average Physical & Social Activity Time Between Groups


```{r,echo=FALSE, message=FALSE, warning=FALSE}


ggplot(df_imputed, aes(x = Schoolwork_Pressure_Binary, 
                     y = Mean_daily_Physical_and_Social_Activity,
                     fill = Schoolwork_Pressure_Binary)) +
  geom_boxplot(alpha = 0.8, show.legend = FALSE) +
  scale_fill_manual(values = pressure_colors) +
  theme_minimal(base_size = 14) +
  labs(
    x = "Pressure Group", 
    y = "Daily Average Physical & Social Activity Time"
  ) +
  theme(
    plot.title = element_text(size = 16, face = "bold")
  )

```



Row
-----------------------------------------------------------------------



### Predictors of Schoolwork Pressure: A Logistic Regression Analysis




```{r,echo=FALSE, message=FALSE, warning=FALSE}

df_selected <- df_imputed %>%
  select(Schoolwork_Pressure_Binary, Mean_daily_screen_time, Mean_daily_Physical_and_Social_Activity, 
         Home_Occupants, Avg_Night_Sleep)

full_model <- glm(Schoolwork_Pressure_Binary ~ ., data = df_selected , family = binomial)
summary.m <- summary(full_model)

knitr::kable(summary.m$coefficients)


```