Thank you for your corrections, after adjusting codes as advised, error still persist
Please see below. Thanks
server code
# Define server function
server <- function(input, output) {
SPC= reactive({req(input$txt1,input$txt2)
#SQL_DB_CONNECTION
con=odbcConnect("dsn",uid="sa", pwd="Analytics10$")
on.exit(odbcClose(con))
sql_db=sqlQuery(con,"input$txt1")
#ORACLE_DB_CONNECTION
con_2 <- odbcConnect("oracle_dsn",uid="DATAANALYTICS", pwd="password10$")
on.exit(odbcClose(con_2))
odbcQuery(con_2,"input$txt2")
oracle_db = sqlGetResults(con_2, as.is=FALSE, errors=FALSE, max=1000000, buffsize=1,nullstring=NA, na.strings="NA", believeNRows=TRUE, dec=getOption("dec"))
#ROW_COUNT_STATISTICS
source_count= nrow(oracle_db)
Destination_count=nrow(sql_db)
spool_status = if (source_count>Destination_count) {print("incomplete")} else if (source_count<Destination_count) {print("duplicate error")} else {print("complete")}
ROW_COUNT_STATISTICS = data.frame(source_count,Destination_count,spool_status)
#CELL_STATISTICS
missing_fields= length(which(is.na(sql_db)))
No_cell_fields=nrow(sql_db)*ncol(sql_db)
complete_fields= No_cell_fields - missing_fields
percentage_cell_completeness= complete_fields/No_cell_fields *100
CELL_STATISTICS= data.frame(missing_fields,complete_fields,percentage_cell_completeness)
SPC= list(ROW_COUNT_STATISTICS=ROW_COUNT_STATISTICS,CELL_STATISTICS=CELL_STATISTICS)
#PLOTTING A GRAPH
options(scipen=999)
library(ggplot2)
#ROW COUNT PLOT
ROW_COUNT= c(source_count,Destination_count)
Table=c("Source","Destination")
ROW_COUNT_STAT_ggplot=data.frame(ROW_COUNT,Table)
plot_1 = ggplot(ROW_COUNT_STAT_ggplot,aes(x= Table,y=ROW_COUNT)) + geom_point(aes(col=spool_status), size=5) + ggtitle("ROW PLOT")
p= if (source_count>Destination_count) {source_count} else {(Destination_count)}
measurement=coord_cartesian(ylim=c(0,p))
plot_rowcount=plot_1+measurement
#CELL_PLOT
fields= c("Missing_fields","Complete_fields")
Cell_count=c(missing_fields,complete_fields)
CELL_PLOT_ggplot=data.frame(fields,Cell_count)
plot_2= ggplot(CELL_PLOT_ggplot,aes(x= fields,y=Cell_count))+ geom_count(aes(fill=percentage_cell_completeness)) + ggtitle("CELL PLOT")
measurement_2=coord_cartesian(ylim=c(0,No_cell_fields))
plot_cell= plot_2 +measurement_2
return (list(P=SPC,plot_cell=plot_cell,plot_rowcount=plot_rowcount))
)}
output$P <-renderTable({
SPC()$P})
output$plot_cell <-renderPlot({
SPC()$plot_cell})
output$plot_rowcount= renderPlot({
SPC()$plot_rowcount})
}
# Create Shiny object
shinyApp(ui = ui, server = server)
#UI CODE
# Define UI
ui <- shinyUI(fluidPage(
headerPanel(title="STATISTICAL PROCESS CONTROL"),
sidebarLayout(
sidebarPanel(
tags$h3("Input:"),
textInput("txt1", "oracle script:", ""),
textInput("txt2", "sql script:", ""),
), # sidebarPanel
submitButton("SUBMIT")
),
mainPanel(
tabsetPanel(type = "tab",
tabPanel("SPC MODEL",tableOutput("P")),
tabPanel("plot_rowcount",plotoutput("plot_rowcount")),
tabPanel("plot_cell",plotoutput("plot_cell"))
) # mainPanel
), # Navbar 1, tabPanel
tabPanel("Navbar 2", "This panel is intentionally left blank"),
tabPanel("Navbar 3", "This panel is intentionally left blank")
) # navbarPage
) # fluidPage
##ERROR
> output$P <-renderTable({
+ SPC()$P})
Error in output$P <- renderTable({ : object 'output' not found
> output$plot_cell <-renderPlot({
+ SPC()$plot_cell})
Error in output$plot_cell <- renderPlot({ : object 'output' not found
> output$plot_rowcount= renderPlot({
+ SPC()$plot_rowcount})
Error in output$plot_rowcount = renderPlot({ : object 'output' not found
>
> }
Error: unexpected '}' in "}"
>
>
> # Create Shiny object
> shinyApp(ui = ui, server = server)
Listening on http://127.0.0.1:3967