1 loading essential R libraries

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(ggtext)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ✔ readr     2.1.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

2 Loading the dataset

.We imported the dataset from a CSV file called “data.csv.” .We handled missing values, ensuring they were correctly identified as NA. .We converted character variables into factors for efficient data processing.

data <- read.csv("data.csv", stringsAsFactors = TRUE, na.strings = c("", "NA"))

3 Renaming the columns header

.We improved the clarity and interpretability of column names by renaming them. .Columns were renamed to reflect the data they contain, facilitating easier analysis in subsequent steps.

data <- rename(data, ConsertForm = In.order.to.proceed..please.fill.out.this.consent.form.)
data <- rename(data, X1 = X1..Below.is.a.list.of.some.of.the.social.media.that.are.available..Please.indicate.which.you.are.aware.of.)
data <- rename(data, X1.1 = X1.1.Are.there.any.other.social.media.available.that.you.are.aware.of.but.didn.t.mention.in.question.1.)
data <- rename(data, X1.2 = X1.2.Please.mention.them.separating.them.by.using.commas.)

data <- rename(data, X2 = X2..Do.you.use.social.media.for.learning.purposes.)
data <- rename(data, X2.1 = X2.1.Please.give.the.reason.s..why.you.do.not.use.social.media.for.learning.purposes.)
data <- rename(data, X2.2 = X2.2.Would.you.be.interested.in.using.social.media.for.learning.purposes.if.the.reason.s..you.mentioned.are.resolved.)

data <- rename(data, X3 = X3..Please.indicate.what.social.media.you.use.for.learning.purposes.)
data <- rename(data, X3.1 = X3.1.Are.there.any.other.social.media..that.you.are.using.for.learning.purposes.but.didn.t.mention.in.question.3.)
data <- rename(data, X3.2 = X3.2.Please.mention.them.separating.them.by.using.commas..)
data <- rename(data, X3.3 = X3.3.If.you.use.more.than.one.social.media.please.specify.which.you.tend.to.use.the.most.)

data <- rename(data, X4 = X4..How.do.you.access.the.social.media.that.you.use.for.learning.purposes.)
data <- rename(data, X4.1 = X4.1..Are.there.any.other.devices.that.you.use.to.access.social.media.but.not.mentioned.in.question.4.)
data <- rename(data, X4.2 = X4.2.Please.mention.them.separating.each.by.using.commas..)
data <- rename(data, X4.3 = X4.3.If.you.ticked.more.than.one.access.method.please.specify.which.one.you.tend.to.use.the.most.)

data <- rename(data, X5 = X5..Where.do.you.access.social.media.for.learning.purposes.)
data <- rename(data, X5.1 = X5.1.Are.there.any.other.places.where.you.access.social.media.but.not.mentioned.in.question.5.)
data <- rename(data, X5.2 = X5.2.Please.mention.them.separating.them.by.using.commas..)
data <- rename(data, X5.3 = X5.2.If.you.ticked.more.than.one.access.point..please.specify.where.you.tend.to.access.the.most.)

data <- rename(data, X6 = X6..What.are.the.Learning.activities.that.you.use.social.media.for.)
data <- rename(data, X6.1 = X6.1.Are.there.any.other.learning.activities.that.you.have.used.social.media.for.but.not.mentioned.in.question.6.)
data <- rename(data, X6.2 = X6.2.Please.mention.them.separating.them.by.using.commas..)

data <- rename(data, X7 = X7..How.often.do.you.use.the.social.media.for.learning.purposes..per.week..)

data <- rename(data, X8ForeignLanguage = X8..Which.academic.subjects.do.you.think.are.better.suited.for.using.social.media.as.a.learning.tool...Foreign.language.)
data <- rename(data, X8SocialSciences = X8..Which.academic.subjects.do.you.think.are.better.suited.for.using.social.media.as.a.learning.tool...Social.sciences.)
data <- rename(data, X8ComputerScience = X8..Which.academic.subjects.do.you.think.are.better.suited.for.using.social.media.as.a.learning.tool...Computer.science.)
data <- rename(data, X8NaturalSciences = X8..Which.academic.subjects.do.you.think.are.better.suited.for.using.social.media.as.a.learning.tool...Natural.sciences.)
data <- rename(data, X8Humanities = X8..Which.academic.subjects.do.you.think.are.better.suited.for.using.social.media.as.a.learning.tool...Humanities.)
data <- rename(data, X8Business = X8..Which.academic.subjects.do.you.think.are.better.suited.for.using.social.media.as.a.learning.tool...Business.)

data <- rename(data, X9Databundles = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...High.cost.of.subscription.to.internet.data.bundles.)
data <- rename(data, X9Smartphones = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...High.cost.of.social.media.enabled.phones..smartphones..)
data <- rename(data, X9Connectivity = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...Poor.internet.connectivity.)
data <- rename(data, X9LowLiteracy = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...Low.ICT.literacy.)
data <- rename(data, X9LowAwareness = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...Low.awareness.of.the.social.media.forlearning.purposes.)
data <- rename(data, X9Unwillingness = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...A.friend.s.unwillingness.to.communicate.learning.issues.through.social.media.)
data <- rename(data, X9Poorknowledge = X9..Below.are.the.possible.constraints.that.could.limit.your.use.of.social.media.for.learning.purposes...Please.indicate.how.much.of.a.constraint.they.are.to.your.use.of.social.media...Poor.knowledge.of.social.media.application.software.and.sites.)

data <- rename(data, Comments = X10..If.you.have.any.further.comments.relating.to.the.use.of.social.media.for.learning.purposes..please.specify.them.below.)
data <- rename(data, Program = Please.specify.the.program.that.best.describes.you.)
data <- rename(data, SubjectWithArts = Please.select.the.two.subject.areas.in.which.you.specialize)
data <- rename(data, SubjectWithSciences = Please.select.the.two.subject.areas.in.which.you.specialize.1)
data <- rename(data, SubjectBed = Please.select.the.subject.area.in.which.you.specialize)

data <- rename(data, YearofStudy = Please.indicate.the.year.of.study.you.are.currently.in.)
data <- rename(data, Background = Before.enrolling.at.DUCE..please.select.the.option.that.best.describes.your.background.)
data <- rename(data, WorkExperience = Please.indicate.the.number.of.years.of.teaching.experience.you.have.)
data <- rename(data, Gender = Please.specify.your.gender.)
data <- rename(data, Age = Please.indicate.your.age.within.the.specified.range.)

4 Participants’ Demographic Information

This section delves into a comprehensive analysis of the demographic information of the dataset’s participants, covering aspects such as age, gender, year of study, educational background, working experience, program of study, and subject combinations. The analysis entails generating frequency tables, calculating percentages, and crafting visualizations to gain a deeper understanding of the distributions.

Methodology:

Step 1: Calculate Frequency Tables

Our analysis commences by calculating frequency tables using the table function. These tables enumerate the occurrences of each variable group within the dataset, shedding light on the distribution patterns.

Step 2: Convert Frequency Tables to Data Frames

To facilitate data manipulation, we convert these frequency tables into data frames. These data frames comprise two vital columns, such as “Age” and “Frequency” or “Gender” and “Frequency,” depending on the specific demographic factor under consideration.

Step 3: Calculate Percentages

To offer a more holistic perspective on the distributions, we compute the percentage of participants in each variable group. This entails dividing the frequency of each group by the total number of participants and rounding the result to ensure clarity.

Step 4: Calculate Total Rows

Incorporating a “Total” row becomes essential at this juncture. This row effectively summarizes the overall count and percentage of all participants, serving as a valuable point of reference.

Step 5: Combine Data Frames with Total Rows

The “Total” row is seamlessly integrated into the previously created data frame using the rbind function. This consolidation consolidates the key insights into a single, cohesive table.

Step 6: Print the Resulting Table

To make these insights easily accessible, we print the final table, featuring variable groups (e.g., age, gender), their frequencies, and respective percentages to the console.

Step 7: Creating a Bar Plot

In addition to tabular representations, we employ the versatile ggplot2 library to generate informative bar plots. These visualizations vividly illustrate the distribution of variable groups, with each bar representing a group’s frequency. Labels are thoughtfully incorporated to display both the count and percentage for each group.

Step 8: Save Visualization as PNG

The resulting visualizations are saved as PNG image files for future reference, each aptly named for the corresponding variable being analyzed (e.g., “age.png,” “gender.png”). These image files are ideally suited for inclusion in dissertation reports or presentations.

4.1 Age Analysis

# Calculate the frequency table
freq_tableAge <- table(data$Age)

# Convert the frequency table to a data frame
df_freq <- data.frame(Age = as.character(names(freq_tableAge)),
                      Frequency = as.numeric(freq_tableAge))

# Calculate the percentage for each age group
total_people <- nrow(data)
df_freq$Percentage <- round((df_freq$Frequency / total_people) * 100)   

# Calculate the total row
total_row <- data.frame(Age = "Total",
                        Frequency = sum(df_freq$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freq <- rbind(df_freq, total_row)

# Print the resulting table
print(df_freq)
##        Age Frequency Percentage
## 1    18-20         3          4
## 2    21-25        60         81
## 3    26-30         9         12
## 4 Above 30         2          3
## 5    Total        74        100
#Saving to csv file
write.csv(df_freq, file = "age.csv")

# Graphical
counts_age <- data %>%
  group_by(Age) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotage <- ggplot(counts_age, aes(x = Age, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Age", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "age.png", plot = plotage, width = 8, height = 4, units = "in")

4.2 Gender Analysis

# Calculate the frequency table
freq_tableSex <- table(data$Gender)

# Convert the frequency table to a data frame
df_freqSex <- data.frame(Sex = as.character(names(freq_tableSex)),
                      Frequency = as.numeric(freq_tableSex))

# Calculate the percentage for each age group
total_people <- nrow(data)
df_freqSex$Percentage <- round((df_freqSex$Frequency / total_people) * 100)


# Calculate the total row
total_row <- data.frame(Sex = "Total",
                        Frequency = sum(df_freqSex$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqSex <- rbind(df_freqSex, total_row)

# Print the resulting table
print(df_freqSex)
##      Sex Frequency Percentage
## 1 Female        18         24
## 2   Male        56         76
## 3  Total        74        100
#Saving
write.csv(df_freqSex, file = "gender.csv")

# Graphical
counts_gender <- data %>%
  group_by(Gender) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotsex <- ggplot(counts_gender, aes(x = Gender, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Sex", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "gender.png", plot = plotsex, width = 8, height = 4, units = "in")

4.3 Year of Study

# Calculate the frequency table
freq_tableYearOfStudy <- table(data$YearofStudy)

# Convert the frequency table to a data frame
df_freqYearOfStudy <- data.frame(Study_Year = as.character(names(freq_tableYearOfStudy)),
                      Frequency = as.numeric(freq_tableYearOfStudy))

# Calculate the percentage for each age group
total_people <- nrow(data)
df_freqYearOfStudy$Percentage <- round((df_freqYearOfStudy$Frequency / total_people) * 100)


# Calculate the total row
total_row <- data.frame(Study_Year = "Total",
                        Frequency = sum(df_freqYearOfStudy$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqYearOfStudy <- rbind(df_freqYearOfStudy, total_row)

# Print the resulting table
print(df_freqYearOfStudy)
##   Study_Year Frequency Percentage
## 1      First        25         34
## 2     Second        24         32
## 3      Third        25         34
## 4      Total        74        100
#Saving
write.csv(df_freqYearOfStudy, file = "yearofstudy.csv")

# Graphical
counts_yrofstudy <- data %>%
  group_by(YearofStudy) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotyearofstudy <- ggplot(counts_yrofstudy, aes(x = YearofStudy, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Year Of Study", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "yearofstudy.png", plot = plotyearofstudy, width = 8, height = 4, units = "in")

4.4 Background Transformation

Before proceeding with the standard analysis steps described earlier, a specific transformation is applied to the ‘Background’ variable. This transformation involves the use of conditional logic to modify certain values. Precisely, if the ‘Background’ value corresponds to “Fresher (I entered directly from a lower level of education),” it is replaced with “Fresher.” In a similar manner, if the value represents “In-service (I have previous teaching experience),” it is converted to “In-service.” All other values within the ‘Background’ variable remain unaltered, ensuring the preservation of the original data integrity. This recoding process is implemented to enhance the clarity and consistency of the ‘Background’ variable, thereby facilitating subsequent analysis.

data$Background <- ifelse(data$Background == "Fresher (I entered directly from a lower level of education).","Fresher",
                          ifelse(data$Background == "In-service(I have previous teaching experience).", "In-service",
                                 data$Background))



# Calculate the frequency table
freq_tableBackground <- table(data$Background)

# Convert the frequency table to a data frame
df_freqBackground <- data.frame(Background = as.character(names(freq_tableBackground)),
                      Frequency = as.numeric(freq_tableBackground))

# Calculate the percentage for each age group
total_people <- nrow(data)
df_freqBackground$Percentage <- round((df_freqBackground$Frequency / total_people) * 100)


# Calculate the total row
total_row <- data.frame(Background = "Total",
                        Frequency = sum(df_freqBackground$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqBackground <- rbind(df_freqBackground, total_row)

# Print the resulting table
print(df_freqBackground)
##   Background Frequency Percentage
## 1    Fresher        72         97
## 2 In-service         2          3
## 3      Total        74        100
#Saving
write.csv(df_freqBackground, file = "background.csv")

# Graphical
counts_background <- data %>%
  group_by(Background) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotbackground <- ggplot(counts_background, aes(x = Background, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Background", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "background.png", plot = plotbackground, width = 8, height = 4, units = "in")

4.5 Working Experience

# Calculate the frequency table
freq_tableWE <- table(data$WorkExperience)

# Convert the frequency table to a data frame
df_freqWE <- data.frame(Work_Experience = as.character(names(freq_tableWE)),
                      Frequency = as.numeric(freq_tableWE))

# Calculate the percentage for each age group
total_people <- data %>% filter(!is.na(WorkExperience)) %>%  nrow()


# Calculate the total row
total_row <- data.frame(Work_Experience = "Total",
                        Frequency = sum(df_freqWE$Frequency))

# Combine the data frame with the total row
df_freqWE <- rbind(df_freqWE, total_row)

# Print the resulting table
print(df_freqWE)
##   Work_Experience Frequency
## 1               1         1
## 2               3         1
## 3           Total         2
#Saving
write.csv(df_freqWE, file = "workingExperience.csv")

4.6 Program

Prior to the standard analysis procedures outlined earlier, a specific transformation is applied to the ‘Program’ variable. This transformation utilizes conditional logic to modify certain values within the variable. Specifically, if the ‘Program’ value corresponds to “Bachelor of Science with Education,” it is replaced with the abbreviation “B.Sc. Ed.” Similarly, if the value represents “Bachelor of Arts with Education,” it is transformed into “B.A. Ed.” In cases where the value is “Bachelor of Education (Science),” it is recoded as “B.Ed. Science,” and if it is “Bachelor of Education (Arts),” it is converted to “B.Ed. Arts.” All other values within the ‘Program’ variable remain unaltered, preserving the original data integrity. This recoding process enhances the clarity and consistency of the ‘Program’ variable for subsequent analysis.

data$Program <- ifelse(data$Program == "Bachelor of Science with Education","B.Sc. Ed.",
                          ifelse(data$Program == "Bachelor of Arts with Education", "B.A. Ed.",
                                 ifelse(data$Program=="Bachelor of Education (Science)", "B.Ed. Science",
                                        ifelse(data$Program=="Bachelor of Education(Arts)", "B.Ed. Arts",
                                 data$Background))))



# Calculate the frequency table
freq_tableProgram <- table(data$Program)

# Convert the frequency table to a data frame
df_freqProgram <- data.frame(Program = as.character(names(freq_tableProgram)),
                      Frequency = as.numeric(freq_tableProgram))

# Calculate the percentage for each age group
total_people <- nrow(data)
df_freqProgram$Percentage <- round((df_freqProgram$Frequency / total_people) * 100)


# Calculate the total row
total_row <- data.frame(Program = "Total",
                        Frequency = sum(df_freqProgram$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqProgram <- rbind(df_freqProgram, total_row)

# Print the resulting table
print(df_freqProgram)
##         Program Frequency Percentage
## 1      B.A. Ed.         8         11
## 2    B.Ed. Arts         5          7
## 3 B.Ed. Science         4          5
## 4     B.Sc. Ed.        57         77
## 5         Total        74        100
#Saving
write.csv(df_freqProgram, file = "program.csv")

# Graphical
counts_program <- data %>%
  group_by(Program) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotprogram <- ggplot(counts_program, aes(x = Program, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Program", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "program.png", plot = plotprogram, width = 8, height = 4, units = "in")

4.7 Subject combination-Bsc Ed

Before proceeding with the standard analysis steps as previously detailed, a specialized transformation is performed on the ‘SubjectWithSciences’ variable. Initially, rows containing missing values (NAs) are filtered out from the dataset to ensure data completeness. Additionally, to improve graph readability, the term “Information Science” within the ‘SubjectWithSciences’ variable is substituted with its acronym “IS.” This transformation simplifies the representation of subject combinations within the ‘SubjectWithSciences’ variable, facilitating a clearer and more informative graphical presentation of the data.

# Filter out rows with NA values in 'SubjectWithSciences'
data_bsc <- data %>% filter(!is.na(SubjectWithSciences))

# Replace "Information Science" with "IS" to enhance graph readability
data_bsc$SubjectWithSciences <- gsub("Information Science", "IS", data_bsc$SubjectWithSciences)

# Calculate the frequency table
freq_tableScience <- table(data_bsc$SubjectWithSciences)

# Convert the frequency table to a data frame
df_freqScience <- data.frame(B.Sc.Ed = as.character(names(freq_tableScience)),
                      Frequency = as.numeric(freq_tableScience))

# Calculate the percentage for each age group
total_people <- nrow(data_bsc)
df_freqScience$Percentage <- round((df_freqScience$Frequency / total_people) * 100)


# Calculate the total row
total_row <- data.frame(B.Sc.Ed = "Total",
                        Frequency = sum(df_freqScience$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqScience <- rbind(df_freqScience, total_row)

# Print the resulting table
print(df_freqScience)
##                 B.Sc.Ed Frequency Percentage
## 1     Biology;Chemistry        32         56
## 2   Chemistry;Geography         3          5
## 3     Chemistry;Physics         5          9
## 4 Mathematics;Economics         1          2
## 5        Mathematics;IS        12         21
## 6   Mathematics;Physics         4          7
## 7                 Total        57        100
#Saving
write.csv(df_freqScience, file = "subjectcombinationScience.csv")

# Graphical
counts_bsc <- data_bsc %>%
  group_by(SubjectWithSciences) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotteachingsc <- ggplot(counts_bsc, aes(x = SubjectWithSciences, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Teaching Subjects", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "teachingsciences.png", plot = plotteachingsc, width = 8, height = 4, units = "in")

4.8 Subject combination-B.A.Ed

Also here a preliminary step is taken to filter out rows with missing values (NAs) within the ‘SubjectWithArts’ variable. This ensures that the analysis is based on complete data, enhancing its reliability.

Furthermore, to improve the visual clarity of the subsequent graphical representation, certain subject names within the ‘SubjectWithArts’ variable are replaced with their respective acronyms. For example, “Geography” becomes “GE,” “History” becomes “HI,” “Linguistics” becomes “LL,” “Kiswahili” becomes “KI,” “French” becomes “FR,” and “Literature” becomes “LT.” This transformation simplifies the presentation of subject combinations, making the resulting plot more reader-friendly and interpretable.

# Filter out rows with NA values in 'SubjectWithArts'
data_arts <- data %>% filter(!is.na(SubjectWithArts))

# Calculate the frequency table
freq_tableArts <- table(data_arts$SubjectWithArts)

# Convert the frequency table to a data frame
df_freqArts <- data.frame(B.A.Ed = as.character(names(freq_tableArts)),
                      Frequency = as.numeric(freq_tableArts))

# Calculate the percentage for each age group
total_people <- nrow(data_arts)
df_freqArts$Percentage <- round((df_freqArts$Frequency / total_people) * 100)

# Calculate the total row
total_row <- data.frame(B.A.Ed = "Total",
                        Frequency = sum(df_freqArts$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqArts <- rbind(df_freqArts, total_row)

# Print the resulting table
print(df_freqArts)
##                   B.A.Ed Frequency Percentage
## 1      Geography;History         1         12
## 2    Geography;Kiswahili         1         12
## 3   Geography;Literature         1         12
## 4       Kiswahili;French         1         12
## 5      Kiswahili;History         1         12
## 6     Linguistics;French         1         12
## 7    Linguistics;History         1         12
## 8 Linguistics;Literature         1         12
## 9                  Total         8        100
#Saving
write.csv(df_freqArts, file = "subjectcombinationArts.csv")

# Graphical
# Replace Subjects with Acronym to enhance graph readability
data_arts$SubjectWithArts <- gsub("Geography", "GE", data_arts$SubjectWithArts)
data_arts$SubjectWithArts <- gsub("History", "HI", data_arts$SubjectWithArts)
data_arts$SubjectWithArts <- gsub("Linguistics", "LL", data_arts$SubjectWithArts)
data_arts$SubjectWithArts <- gsub("Kiswahili", "KI", data_arts$SubjectWithArts)
data_arts$SubjectWithArts <- gsub("French", "FR", data_arts$SubjectWithArts)
data_arts$SubjectWithArts <- gsub("Literature", "LT", data_arts$SubjectWithArts)


counts_arts <- data_arts %>%
  group_by(SubjectWithArts) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotteachingARTS <- ggplot(counts_arts, aes(x = SubjectWithArts, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Teaching Subjects", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "teachingARTS.png", plot = plotteachingARTS, width = 8, height = 4, units = "in")

4.9 Subject combination-BED

# Filter out rows with NA values in 'SubjectBed'
data_bed <- data %>% filter(!is.na(SubjectBed))

# Calculate the frequency table
freq_tableBed <- table(data_bed$SubjectBed)

# Convert the frequency table to a data frame
df_freqBed <- data.frame(BED = as.character(names(freq_tableBed)),
                      Frequency = as.numeric(freq_tableBed))

# Calculate the percentage for each age group
total_people <- nrow(data_bed)
df_freqBed$Percentage <- round((df_freqBed$Frequency / total_people) * 100)

# Calculate the total row
total_row <- data.frame(BED = "Total",
                        Frequency = sum(df_freqBed$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqBed <- rbind(df_freqBed, total_row)

# Print the resulting table
print(df_freqBed)
##           BED Frequency Percentage
## 1   Chemistry         1         11
## 2   Geography         1         11
## 3     History         1         11
## 4   Kiswahili         1         11
## 5 Linguistics         1         11
## 6  Literature         1         11
## 7     Physics         3         33
## 8       Total         9        100
#Saving
write.csv(df_freqBed, file = "subjectcombinationBed.csv")

# Graphical
counts_bed <- data_bed %>%
  group_by(SubjectBed) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotteachingBED <- ggplot(counts_bed, aes(x = SubjectBed, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Teaching Subject", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "teachingBED.png", plot = plotteachingBED, width = 8, height = 4, units = "in")

5 Findings on social media utilization for learning

5.1 X1

countsX1 <- data %>%
  separate_rows(X1, sep = ";") %>%
  group_by(X1) %>%
  summarise(count = n()) %>%
  rename(SM = X1) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

# Create a bar plot of the counts with percentages as labels
plotX1 <- ggplot(countsX1, aes(x = SM, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Social Media", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "SM_awarness.png", plot = plotX1, width = 8, height = 4, units = "in")
# X1.1
#X1.2
table(data$X1.1)
## 
##  No Yes 
##  45  29
counts_X1.2 <- data %>%
  filter(!is.na(X1.2))%>%
  separate_rows(X1.2, sep = ",") %>%
  group_by(X1.2, ignore.case=FALSE) %>%
  summarise(count = n()) %>%
  rename(SM = X1.2) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))
## `summarise()` has grouped output by 'X1.2'. You can override using the
## `.groups` argument.
counts_X1.2
## # A tibble: 43 × 4
## # Groups:   SM [43]
##    SM            ignore.case count percentage
##    <chr>         <lgl>       <int>      <dbl>
##  1 "Telegram "   FALSE           4        100
##  2 " "           FALSE           2        100
##  3 "Instagram"   FALSE           2        100
##  4 "Telegram"    FALSE           2        100
##  5 "Tiktok"      FALSE           2        100
##  6 " Facebook"   FALSE           1        100
##  7 " MSN"        FALSE           1        100
##  8 " QQ"         FALSE           1        100
##  9 " Qzone"      FALSE           1        100
## 10 " Sina Weibo" FALSE           1        100
## # ℹ 33 more rows
write.csv(counts_X1.2, file = "othersSM.csv")

5.2 X2

# Calculate the frequency table
freq_tableX2 <- table(data$X2)

# Convert the frequency table to a data frame
df_freqX2 <- data.frame(X2 = as.character(names(freq_tableX2)),
                      Frequency = as.numeric(freq_tableX2))

# Calculate the percentage for each age group
total_people <- nrow(data)
df_freqX2$Percentage <- round((df_freqX2$Frequency / total_people) * 100)


# Calculate the total row
total_row <- data.frame(X2 = "Total",
                        Frequency = sum(df_freqX2$Frequency),
                        Percentage = 100)

# Combine the data frame with the total row
df_freqX2 <- rbind(df_freqX2, total_row)

# Print the resulting table
print(df_freqX2)
##      X2 Frequency Percentage
## 1    No         3          4
## 2   Yes        71         96
## 3 Total        74        100
# Graphical
countsX2 <- data %>%
  group_by(X2) %>%
  summarise(count = n()) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

plotX2 <- ggplot(countsX2, aes(x = X2, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Social Media for Learning?", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Q2.png", plot = plotX2, width = 8, height = 4, units = "in")

5.3 X3

countsX3 <- data %>%
  filter(!is.na(X3)) %>%
  separate_rows(X3, sep = ";") %>%
  group_by(X3) %>%
  summarise(count = n()) %>%
  rename(SM = X3) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

# Create a bar plot of the counts with percentages as labels
plotX3 <- ggplot(countsX3, aes(x = SM, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Social media", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Q3.png", plot = plotX3, width = 8, height = 4, units = "in")

5.4 X4

countsX4 <- data %>%
  filter(!is.na(X4))%>%
  separate_rows(X4, sep = ";") %>%
  group_by(X4) %>%
  summarise(count = n()) %>%
  rename(SM = X4) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

# Create a bar plot of the counts with percentages as labels
plotmedium <- ggplot(countsX4, aes(x = SM, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.3, color = "black", fontface="bold") +
  labs(x = "Access medium", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Q4.png", plot = plotmedium, width = 8, height = 4, units = "in")

5.5 X5

countsX5 <- data %>%
  filter(!is.na(X5))%>%
  separate_rows(X5, sep = ";") %>%
  group_by(X5) %>%
  summarise(count = n()) %>%
  rename(SM = X5) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

# Create a bar plot of the counts with percentages as labels
plotX5 <- ggplot(countsX5, aes(x = SM, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.2, color = "black", fontface="bold") +
  labs(x = "Access point", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Q5.png", plot = plotX5, width = 8, height = 4, units = "in")

5.6 X6

counts_activities <- data %>%
  filter(!is.na(X6))%>%
  separate_rows(X6, sep = ";") %>%
  group_by(X6) %>%
  summarise(count = n()) %>%
  rename(Activities = X6) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100))

counts_activities$Activities_acronym <- ifelse(counts_activities$Activities=="Accessing learning resources (e.g. articles, journals, books)","ALR",
            ifelse(counts_activities$Activities=="Accessing lecture notes or course materials, for example, for lecture preparation","ALN",
              ifelse(counts_activities$Activities=="Collaborating with peers on group assignments","CWP",
                ifelse(counts_activities$Activities=="Giving and/or receiving feedback from/to instructors","GRF",
                  if_else(counts_activities$Activities=="Sharing ideas and insights with peers (e.g. Group discussions)","SII",
                    ifelse(counts_activities$Activities=="Preparing for exams or quizzes","PFE",
                      ifelse(counts_activities$Activities=="Accessing student organizations or clubs information’s","ASO",
                        ifelse(counts_activities$Activities=="Giving and/or receiving support from/to fellow students","GRS",
                          ifelse(counts_activities$Activities=="Participating in online classes or webinars","POC",
                            ifelse(counts_activities$Activities=="Applying for internships and/or field practice","AIF", counts_activities$Activities))))))))))


# Create a bar plot of the counts with percentages as labels
plotQ6 <- ggplot(counts_activities, aes(x = Activities_acronym, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Learning Activities", y = "Frequency") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Q6.png", plot = plotQ6, width = 8, height = 4, units = "in")

5.7 X7

data_Q7 <- data %>% filter(!is.na(X7))
data_Q7 <- data_Q7[data_Q7$X7<=168,]

# Calculate the range
range_hours <- range(data_Q7$X7)
range_hours
## [1]  1 72
# Calculate the mean
mean_hours <- mean(data_Q7$X7)
mean_hours
## [1] 9.285714
# Calculate the median
median_hours <- median(data_Q7$X7)
median_hours
## [1] 5.5
# Calculate the mode using the table function
mode_hours <- as.numeric(names(table(data_Q7$X7[which.max(table(data_Q7$X7))])))
mode_hours
## [1] 5
# Calculate the standard deviation
sd_hours <- sd(data_Q7$X7)
sd_hours
## [1] 13.5915
# Calculate the interquartile range (IQR)
iqr_hours <- IQR(data_Q7$X7)
iqr_hours
## [1] 3
# Create a histogram to visualize the data distribution
plotx7 <- ggplot(data_Q7, aes(x = X7)) +
  geom_histogram(binwidth = 5, fill = "steelblue", color = "black") +
  labs(x = "Hours Spent on Social Media", y = "Frequency") +
  theme_classic() +
  scale_x_continuous(breaks = seq(min(data_Q7$X7), max(data_Q7$X7), by=2))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Q7.png", plot = plotx7, width = 8, height = 4, units = "in")

5.8 X8

5.8.1 ForeignLanguage

counts_X81 <- data %>%
  filter(!is.na(X8ForeignLanguage)) %>%
  group_by(X8ForeignLanguage) %>%
  summarise(count = n()) %>%
  rename(Foreign_Language=X8ForeignLanguage) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))
counts_X81
## # A tibble: 5 × 3
##   Foreign_Language    count percentage
##   <fct>               <int>      <dbl>
## 1 extremely suited       29      40.8 
## 2 Somewhat suited        15      21.1 
## 3 Neutral                13      18.3 
## 4 Somewhat not suited     9      12.7 
## 5 not suited at all       5       7.04
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X81, aes(x = Foreign_Language, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Foreign Language") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Foreign_Language.png", plot = plot, width = 8, height = 4, units = "in")

5.8.2 SocialSciences

counts_X82 <- data %>%
  filter(!is.na(X8SocialSciences)) %>%
  group_by(X8SocialSciences) %>%
  summarise(count = n()) %>%
  rename(SocialSciences=X8SocialSciences) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X82, aes(x = SocialSciences, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Social Sciences") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "SocialSciences.png", plot = plot, width = 8, height = 4, units = "in")

5.8.3 ComputerScience

counts_X83 <- data %>%
  filter(!is.na(X8ComputerScience)) %>%
  group_by(X8ComputerScience) %>%
  summarise(count = n()) %>%
  rename(ComputerScience=X8ComputerScience) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X83, aes(x = ComputerScience, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Computer Science") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "ComputerScience.png", plot = plot, width = 8, height = 4, units = "in")

5.8.4 NaturalSciences

counts_X84 <- data %>%
  filter(!is.na(X8NaturalSciences)) %>%
  group_by(X8NaturalSciences) %>%
  summarise(count = n()) %>%
  rename(NaturalSciences=X8NaturalSciences) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X84, aes(x = NaturalSciences, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Natural Sciences") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "NaturalSciences.png", plot = plot, width = 8, height = 4, units = "in")

5.8.5 Humanities

counts_X85 <- data %>%
  filter(!is.na(X8Humanities)) %>%
  group_by(X8Humanities) %>%
  summarise(count = n()) %>%
  rename(Humanities=X8Humanities) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X85, aes(x = Humanities, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Humanities") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Humanities.png", plot = plot, width = 8, height = 4, units = "in")

5.8.6 Business

counts_X86 <- data %>%
  filter(!is.na(X8Business)) %>%
  group_by(X8Business) %>%
  summarise(count = n()) %>%
  rename(Business=X8Business) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X86, aes(x = Business, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Business") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "Business.png", plot = plot, width = 8, height = 4, units = "in")

5.9 X9

5.9.1 Databundles

counts_X91 <- data %>%
  filter(!is.na(X9Databundles)) %>%
  group_by(X9Databundles) %>%
  summarise(count = n()) %>%
  rename(Databundles=X9Databundles) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X91
## # A tibble: 4 × 3
##   Databundles            count percentage
##   <fct>                  <int>      <dbl>
## 1 Significant constraint    43      60.6 
## 2 Constraint                21      29.6 
## 3 Minor constraint           5       7.04
## 4 Not a constraint           2       2.82
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X91, aes(x = Databundles, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Databundles") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9Databundles.png", plot = plot, width = 8, height = 4, units = "in")

5.9.2 Smartphones

counts_X92 <- data %>%
  filter(!is.na(X9Smartphones)) %>%
  group_by(X9Smartphones) %>%
  summarise(count = n()) %>%
  rename(Smartphones=X9Smartphones) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X92
## # A tibble: 4 × 3
##   Smartphones            count percentage
##   <fct>                  <int>      <dbl>
## 1 Significant constraint    30      42.2 
## 2 Constraint                22      31.0 
## 3 Minor constraint          12      16.9 
## 4 Not a constraint           7       9.86
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X92, aes(x = Smartphones, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Smartphones") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9Smartphones.png", plot = plot, width = 8, height = 4, units = "in")

5.9.3 Connectivity

counts_X93 <- data %>%
  filter(!is.na(X9Connectivity)) %>%
  group_by(X9Connectivity) %>%
  summarise(count = n()) %>%
  rename(Connectivity=X9Connectivity) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X93
## # A tibble: 4 × 3
##   Connectivity           count percentage
##   <fct>                  <int>      <dbl>
## 1 Significant constraint    28      39.4 
## 2 Constraint                26      36.6 
## 3 Minor constraint          12      16.9 
## 4 Not a constraint           5       7.04
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X93, aes(x = Connectivity, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Connectivity") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9Connectivity.png", plot = plot, width = 8, height = 4, units = "in")

5.9.4 LowLiteracy

counts_X94 <- data %>%
  filter(!is.na(X9LowLiteracy)) %>%
  group_by(X9LowLiteracy) %>%
  summarise(count = n()) %>%
  rename(LowLiteracy=X9LowLiteracy) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X94
## # A tibble: 4 × 3
##   LowLiteracy            count percentage
##   <fct>                  <int>      <dbl>
## 1 Constraint                24       33.8
## 2 Significant constraint    19       26.8
## 3 Minor constraint          15       21.1
## 4 Not a constraint          13       18.3
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X94, aes(x = LowLiteracy, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("LowLiteracy") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9LowLiteracy.png", plot = plot, width = 8, height = 4, units = "in")

5.9.5 LowAwareness

counts_X95 <- data %>%
  filter(!is.na(X9LowAwareness)) %>%
  group_by(X9LowAwareness) %>%
  summarise(count = n()) %>%
  rename(LowAwareness=X9LowAwareness) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X95
## # A tibble: 4 × 3
##   LowAwareness           count percentage
##   <fct>                  <int>      <dbl>
## 1 Constraint                20       28.2
## 2 Not a constraint          20       28.2
## 3 Significant constraint    19       26.8
## 4 Minor constraint          12       16.9
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X95, aes(x = LowAwareness, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("LowAwareness") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9LowAwareness.png", plot = plot, width = 8, height = 4, units = "in")

5.9.6 Unwillingness

counts_X96 <- data %>%
  filter(!is.na(X9Unwillingness)) %>%
  group_by(X9Unwillingness) %>%
  summarise(count = n()) %>%
  rename(Unwillingness=X9Unwillingness) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X96
## # A tibble: 4 × 3
##   Unwillingness          count percentage
##   <fct>                  <int>      <dbl>
## 1 Constraint                26       36.6
## 2 Minor constraint          17       23.9
## 3 Not a constraint          15       21.1
## 4 Significant constraint    13       18.3
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X96, aes(x = Unwillingness, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Unwillingness") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9Unwillingness.png", plot = plot, width = 8, height = 4, units = "in")

5.9.7 Poorknowledge

counts_X97 <- data %>%
  filter(!is.na(X9Poorknowledge)) %>%
  group_by(X9Poorknowledge) %>%
  summarise(count = n()) %>%
  rename(Poorknowledge=X9Poorknowledge) %>%
  arrange(desc(count)) %>%
  mutate(percentage = round(count / sum(count) * 100, 2))

counts_X97
## # A tibble: 4 × 3
##   Poorknowledge          count percentage
##   <fct>                  <int>      <dbl>
## 1 Significant constraint    22       31.0
## 2 Not a constraint          18       25.4
## 3 Constraint                17       23.9
## 4 Minor constraint          14       19.7
# Create a bar plot of the counts with percentages as labels
plot <- ggplot(counts_X97, aes(x = Poorknowledge, y = count)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  geom_text(aes(label = paste0(count, " (", percentage, "%)")), vjust = -0.1, color = "black", fontface="bold") +
  labs(x = "Rank", y = "Frequency") +
  ggtitle("Poorknowledge") +
  theme_classic() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        axis.title.x = element_text(face = "bold"))

# Save the plot as an image file (e.g., PNG format)
ggsave(filename = "X9Poorknowledge.png", plot = plot, width = 8, height = 4, units = "in")