Has anyone experienced the "Not Found" error usin the shiny package in R?

I keep seeing 'Not Found' when trying to load my Shiny application, it seems to be that R cannot find the Shiny server, I have tried reinstalling all packages and still no luck.

The strange thing is that it works the first time I open R Studio, then it doesn't hereafter..

I have attatched a working example and a screenshot for insight.

---
title: "Benchmarking Algorithms for Credit Card Fraud Detection"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: ["menu"]
    runtime: shiny
    #options: (shiny.maxRequestSize = 1500*1024^2)
---
```{r setup, include=FALSE}
suppressPackageStartupMessages({
library(shiny)
library(flexdashboard)
library(datasets)
library(caTools)
library(hydroGOF)
})

```

Column {.tabset}
-------------------------------------

### Linear Regression Model

```{r}
ui <- fluidPage(

  titlePanel("Upload Transaction Data Set"),

  sidebarLayout(

    sidebarPanel(

      fileInput("file1", "Choose CSV File",
                multiple = FALSE,
                accept = c("text/csv",
                           "text/comma-separated-values,text/plain",
                           ".csv")),

      p("The transaction data file must contain a 'Class' column that specifies the number 1 for fraudulent transactions, and 0 otherwise"),

      p("The 'Actual' graph exhibits the real calculations of the uploaded data, and the 'predicted' graph exhibits the predicted 'Class' column based on the other features of data included in your upload.")

    ),

    mainPanel(
    h1("Models"),
    plotOutput("actual"),
    plotOutput("prediction"),
    h1("Root Mean Square Error (RMSE) Accuracy %"),
    verbatimTextOutput("accuracy"),
    h1("Summary"),
    verbatimTextOutput("summary")

    )
  )
)

server = function(input,output){
  options(shiny.maxRequestSize=500*1024^2)
  thedata = reactive({
  req(input$file1)
  read.csv(file = input$file1$datapath)
  })

   output$prediction = renderPlot({
   req(thedata())

   set.seed(2)

   #Split data
   split <- sample.split(thedata(), SplitRatio=0.7)
   thedata <- subset(thedata(), split=TRUE)
   actual <- subset(thedata(), split=FALSE)

   #Create the model
    model <- lm(Class ~.,data = thedata())

   #Prediction
   prediction <- predict(model, actual)
   distPred <- predict(model, actual)

   #Comparing predicted vs actual model
   plot(prediction,type = "l",lty= 1.8,col = "blue")
   lines(prediction, type = "l", col = "blue")

   })

   output$actual = renderPlot({
   req(thedata())
   set.seed(2)

   split <- sample.split(thedata()$Class,0.7)

   thedata <- subset(thedata(),split)
   actual <- subset(thedata(),!split)

   model <- lm(Class ~.,data = thedata())

   prediction <- predict(model, actual)

   plot(actual$Class,type = "l",lty= 1.8,col = "blue")

output$accuracy <- renderPrint({
    rmse <- sqrt(mean(prediction-thedata$Class)^2)/diff(range(thedata$Class))
    rmse
  })
})

output$summary <- renderPrint({
    model <- lm(Class ~.,data = thedata())
    summary (model)
    })
}

shinyApp(ui, server)

```

-------------------------------------

### Logistic Regression Model

```{r}
ui <- fluidPage(

  titlePanel("Upload Transaction Data Set"),

  sidebarLayout(

    sidebarPanel(

      fileInput("file1", "Choose CSV File",
                multiple = FALSE,
                accept = c("text/csv",
                           "text/comma-separated-values,text/plain",
                           ".csv")),

  p("The transaction data file must contain a 'Class' column that specifies the number 1 for fraudulent transactions, and 0 otherwise"),

  p("The 'Actual' graph exhibits the real calculations of the uploaded data, and the 'predicted' graph exhibits the predicted 'Class' column based on the other features of data included in your upload.")

    ),

  mainPanel(
    h1("Models"),
    plotOutput("actual"),
    plotOutput("prediction"),
    h1("Confusion Matrix"),
    verbatimTextOutput("confMatrix"),
    h1("Accuracy (%)"),
    verbatimTextOutput("accuracy"),
    h1("Summary"),
    verbatimTextOutput("summary")

    )
  )
)

server = function(input,output){
  options(shiny.maxRequestSize=500*1024^2) #Max File Size
  thedata = reactive({
  req(input$file1)
  read.csv(file = input$file1$datapath)
  })

   output$prediction = renderPlot({
   req(thedata())

   #Split Data
   split <- sample.split(thedata(), SplitRatio=0.7)
   train <- subset(thedata(), split=TRUE)
   Actual <- subset(thedata(), split=FALSE)

   #Create Model
   mymodel <- glm(Class ~., data = thedata(), family = binomial, control = list(maxit = 50))

   #Prediction
   Prediction <- predict(mymodel, Actual, type="response")

   #Predicted Model
   plot(Prediction,type = "l",lty= 1.8,col = "blue")

  })

   output$actual = renderPlot({
   req(thedata())

   # Split Data
   split <- sample.split(thedata(), SplitRatio=0.7)
   train <- subset(thedata(), split=TRUE)
   Actual <- subset(thedata(), split=FALSE)

   #Create Model
   mymodel <- glm(Class ~., data = thedata(), family = binomial, control = list(maxit = 50))

   #Prediction
   Prediction <- predict(mymodel, Actual, type="response")

   #Actual Model
   plot(Actual$Class,type = "l",lty= 1.8,col = "blue")

  output$confMatrix <- renderPrint({
    confusionMatrix <- table(Actual_Value=train$Class, Predicted_Values=Prediction > 0.5)
    confusionMatrix
    })

  output$accuracy <- renderPrint({
    confusionMatrix <- table(Actual_Value=train$Class, Predicted_Values=Prediction > 0.5)
    (confusionMatrix[[1,1]] + confusionMatrix[[2,2]]) / sum(confusionMatrix) *100
    })
  })

   output$summary <- renderPrint({
    mymodel <- glm(Class ~., data = thedata(), family = binomial, control = list(maxit = 50))
    summary (mymodel)
    })
}

shinyApp(ui, server)

```   

-------------------------------------

### Bayesian Model

```{r}

```

Not_Found.PNG

I didn't find the clues in your post but I may have missed it. Anyhow I have run into non-shiny issues where the DNS was some ISP that was (rap. So with that in mind I have two ideas. 1. Test with a DNS like 8.8.8.8 and 2. Double check your shiny? server is running and responding on port 4616.

Shiny is definately working, I am changing the file from an R Markdown file to a regular R file running shiny because I think running Flexdashboard with Shiny in an R Markdown file has its limits

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.