I have created my shinyapp on relative importance index, I have registered with shinyapps.io and deployed it on my Rstudio. I run the app and works perfectly but when published it what I have on the browser is %PDF-1.5 %
. What can I do?
see my code
# Install and load necessary libraries
if (!requireNamespace("shiny", quietly = TRUE)) {
install.packages("shiny")
}
if (!requireNamespace("readxl", quietly = TRUE)) {
install.packages("readxl")
}
if (!requireNamespace("lubridate", quietly = TRUE)) {
install.packages("lubridate")
}
if (!requireNamespace("ggplot2", quietly = TRUE)) {
install.packages("ggplot2")
}
library(shiny)
library(readxl)
library(lubridate)
library(ggplot2)
# Define the UI
ui <- fluidPage(
titlePanel("Relative Importance Index (RII) Analysis"),
sidebarLayout(
sidebarPanel(
fileInput("file", "Choose Excel file", accept = c(".xlsx")),
actionButton("runAnalysis", "Run Analysis")
),
mainPanel(
tabsetPanel(
tabPanel("RII Table", tableOutput("riiTable")),
tabPanel("Radar Chart", plotOutput("radarChart")),
tabPanel("Bar Chart", plotOutput("barChart"))
)
)
)
)
# Define the server
server <- function(input, output) {
data <- reactive({
req(input$file)
read_excel(input$file$datapath)
})
observeEvent(input$runAnalysis, {
likert_data <- data()[, c("FR1", "FR2", "FR3", "FR4", "FR5", "FR6", "FR7", "FR8")]
weights <- c(1, 2, 3, 4, 5)
TotalF <- colSums(likert_data * weights)
TotalW <- sum(weights) * nrow(likert_data)
rii_values <- TotalF / TotalW
mean_values <- colMeans(likert_data)
result_data <- data.frame(
Item = names(rii_values),
Mean = mean_values,
TotalF = as.integer(TotalF), # Convert TotalF to whole number
TotalW = as.integer(TotalW), # Convert TotalW to whole number
RII = rii_values,
Rank = as.integer(rank(-rii_values)) # Convert Rank to whole number
)
output$riiTable <- renderTable(result_data, digits = 4, caption = "Relative importance index for FR")
output$radarChart <- renderPlot({
ggplot(result_data, aes(x = Item, y = RII)) +
geom_polygon(fill = "lightblue", color = "blue", size = 1) +
geom_point(color = "red", size = 3) +
theme_minimal() +
coord_polar() +
labs(title = "Radar Chart of RII Analysis for Failure Rate in Mathematics",
subtitle = "Factors influencing the failure rate based on Relative Importance Index (RII)",
caption = "Source: Selected schools in Nigeria",
x = NULL,
y = "Relative Importance Index (RII)")
})
output$barChart <- renderPlot({
ggplot(result_data, aes(x = Item, y = RII, fill = factor(Rank))) +
geom_bar(stat = "identity") +
labs(title = "Relative Importance Index (RII) Analysis",
x = "Items",
y = "RII") +
scale_fill_manual(values = rainbow(length(unique(result_data$Rank)))) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
})
})
}
# Run the Shiny app
shinyApp(ui, server)
and my data
> dput(data)
structure(list(FR1 = c(3, 3, 2, 5, 5, 5, 5, 4, 4, 2, 5, 2, 4,
5, 3, 4, 3, 4, 2, 4, 5, 5, 3, 4, 5, 2, 4, 5, 4, 1, 5, 5, 4, 3,
4, 4, 2, 3, 5, 4, 3, 4, 5, 4, 4, 4, 4, 3, 3, 5, 5, 5, 3, 5, 5,
3, 3, 4, 4, 4, 5, 4, 4, 5, 3, 5, 5, 4, 4, 2, 2, 5, 5, 4, 5, 3,
4, 4, 4, 5, 4, 3, 4, 5, 5, 4, 4, 3, 2, 4, 4, 5, 5, 5, 4, 4, 3,
4, 3, 2, 3, 5, 3, 2, 5, 4, 5, 2, 5, 4, 3, 2, 3, 3, 5, 5, 5, 4,
3, 4, 4, 3, 4, 4, 4, 5, 4, 2, 5, 3, 4, 3, 3, 3, 4, 1, 4, 5, 5,
3, 5, 4, 4, 4, 4, 2, 4, 5, 5, 3, 5, 4, 2, 3, 4, 5, 4, 3, 4, 5,
3, 5, 3, 5, 3, 3, 4, 3, 4, 4, 4, 5, 4, 5, 5, 2, 3, 5, 5, 3, 5,
3, 4, 4, 3, 5, 3, 3, 3, 3, 1, 3, 3, 3, 3, 2, 4, 4, 5, 3, 3, 4,
5, 3, 3, 3, 3, 3, 4, 3, 4), FR2 = c(2, 4, 1, 5, 4, 5, 5, 5, 4,
1, 2, 4, 4, 4, 2, 4, 4, 4, 1, 5, 5, 5, 3, 4, 4, 2, 4, 5, 4, 3,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