R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(shiny)
## Warning: package 'shiny' was built under R version 4.4.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.3
## 
## 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(readxl)
## Warning: package 'readxl' was built under R version 4.4.3
library(bslib)
## Warning: package 'bslib' was built under R version 4.4.3
## 
## Attaching package: 'bslib'
## The following object is masked from 'package:utils':
## 
##     page
#Interpretation: We upload the core packages needed for data analysis

df<- read_excel("C:\\Users\\Dell\\Desktop\\Oman_Employment_Data_Realistic.xlsx")
df
#User interface : select a sector from a dropdown menu, which triggers updates to both a table and a bar plot.
ui<- fluidPage(
  titlePanel("Oman Employment Data Analysis"),
  
  sidebarLayout(
    sidebarPanel(
      selectInput("sector", "Choose Sector:", choices = unique(df$Sector)),
      plotOutput("salaryPlot")
    ),
    
    mainPanel(
      tableOutput("sectorData")
    )
  )
)

# Server Logic:The data is filtered based on the selected sector, and the filtered results are displayed in a table and a plot showing the average salary by job title in the chosen sector.
server <- function(input, output) {
  
  # Filter the data based on the selected sector
  filteredData <- reactive({
    df %>% filter(Sector == input$sector)
  })
  
# Render the filtered data in a table
output$sectorData <- renderTable({
  filteredData()
})
  
# Create a plot for the average salary
output$salaryPlot <- renderPlot({
  ggplot(filteredData(), aes(x = Job_Title, y = Average_Salary_OMR)) +
    geom_bar(stat = "identity", fill = "steelblue") +
    labs(title = paste("Average Salary in", input$sector, "Sector"),
          x = "Job Title",
          y = "Average Salary (OMR)") +
    theme(axis.text.x = element_text(angle = 45, hjust = 1))
})
}

# Run the app
shinyApp(ui = ui, server = server)
Shiny applications not supported in static R Markdown documents
#summary interpretation:A Shiny app for analyzing Oman's employment data is produced using this R code.  After the user chooses a sector from a dropdown menu, the app shows the average income for various job titles in that sector in a table and bar plot.  Depending on the sector that was chosen, the data is reactively filtered, and the display is updated appropriately.  Users of the app can examine and view wage trends across a number of Omani employment sectors.