闪亮的应用程序错误源调试

时间:2017-10-23 19:49:19

标签: r csv shiny

我正在加载一个闪亮的应用程序,用于通过构建在csv文件上的逻辑回归模型中的新输入变量来冒险。任何调试的想法?加载应用程序时的错误消息如下:

ERROR: Error sourcing C:\Users\Vincent\AppData\Local\Temp\RtmpATsPEW\filef604271fa   with such message on the R studio console : 
Warning in checkEncoding(file) :
  The input file C:/Users/Vincent/Documents/R Apprentissage/Applications Shiny/Prediction insuffisance renale aigue chez les ileostomises.R/Prediction IRA chez ileostomises.R does not seem to be encoded in UTF8
Warning: invalid input found on input connection 'C:/Users/Vincent/Documents/R Apprentissage/Applications Shiny/Prediction insuffisance renale aigue chez les ileostomises.R/Prediction IRA chez ileostomises.R'
Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) : 
  C:/Users/Vincent/Documents/R Apprentissage/Applications Shiny/Prediction insuffisance renale aigue chez les ileostomises.R/Pr:5:14: unexpected INCOMPLETE_STRING
4: ui <- fluidPage(
5:   titlePanel("Pr
                ^
Warning: Error in sourceUTF8: Error sourcing C:\Users\Vincent\AppData\Local\Temp\RtmpATsPEW\filef604271fa
Stack trace (innermost first):
    1: runApp
Error : Error sourcing C:\Users\Vincent\AppData\Local\Temp\RtmpATsPEW\filef604271fa
 ui <- fluidPage(
  titlePanel("Prédiction d'insuffisance rénale aiguë chez les iléostomisés"),
   sidebarLayout(
     sidebarPanel(

  checkboxGroupInput("checkboxGroup1", "Cancer colorectal", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup2", "Maladie cardiovasculaire", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup3", "Maladie thrombo-embolique veineuse", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup4","Démence", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup5","Résection rectale antérieure", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup6","Hémicolectomie gauche", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup7","Chimiothérapie per iléostomie", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup8","Iléostomie à haut débit", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  checkboxGroupInput("checkboxGroup9","Deshydratation", 
                     choices = list("Absente" = 1, 
                                    "Présente" = 2),
                     selected = 1),

  sliderInput("slider1","Créatininémie pré-opératoire", min = 20, max = 400, value = 100),

  sliderInput("slider2", "Age", min = 0, max = 100, value = 50)
),

  mainPanel(
tabPanel("Probabilité de développer une insuffisance rénale aiguë",textOutput("pred1")))
 ))



data_app <- read.csv("./data/DatasetpourShiny", header = TRUE, sep = ";", quote = "\"", dec = ",", fill = TRUE)
server <- function(input, output) {

  model1 <- glm(Augmentation.creat.26.umolL.en.48H ~ 
              Cancer.colique.ou.rectal + 
              ATCD.maladie.cardiovasculaire +
              ATCD.MTEV +
              Demences +
              Resection.anterieure.rectum +
              Type.colectomie_2 +
              Chimio.porteur.ileostomie +
              Stomie.a.haut.debit +
              Deshydratation.post.op +
              Creatininemie.pre.operatoire +
              Age, family= "binomial", data = data_app)

  model1pred <- reactive ({
Cancer.colique.ou.rectalInput <- input$checkboxGroup1  
ATCD.maladie.cardiovasculaireInput <- input$checkboxGroup2
ATCD.MTEVInput <- input$checkboxGroup3
DemencesInput <- input$checkboxGroup4
Resection.anterieure.rectumInput <- input$checkboxGroup5
Type.colectomie_2Input <- input$checkboxGroup6
Chimio.porteur.ileostomieInput <- input$checkboxGroup7
Stomie.a.haut.debitInput <- input$checkboxGroup8
Deshydratation.post.opInput <- input$checkboxGroup9
Creatininemie.pre.operatoireInput <- input$slider1
AgeInput <- input$slider2

    predict(model1, 
        newdata = data.frame(
          Cancer.colique.ou.rectal =  Cancer.colique.ou.rectalInput,
          ATCD.maladie.cardiovasculaire = ATCD.maladie.cardiovasculaireInput,
          ATCD.MTEV = ATCD.MTEVInput,
          Demences = DemencesInput,
          Resection.anterieure.rectum = Resection.anterieure.rectumInput,
          Type.colectomie_2 = Type.colectomie_2Input,
          Chimio.porteur.ileostomie  =  Chimio.porteur.ileostomieInput,
          Stomie.a.haut.debit = Stomie.a.haut.debitInput,
          Deshydratation.post.op = Deshydratation.post.opInput,
          Creatininemie.pre.operatoire = Creatininemie.pre.operatoireInput,
          Age = AgeInput
        ))
  })
  output$pred1 <- rendertext({
exp(model1pred())/(1+exp(model1pred()))*100
  })
 }



shinyApp(ui = ui, server = server)

3 个答案:

答案 0 :(得分:1)

您的UI中的特殊字符编码似乎有问题。确保使用utf8编码保存文件。 看看这里:Shiny Documentation on special characters

我将您的代码复制到RStudio中的文件中并使用UTF-8编码保存。它正是这样工作的。

希望有所帮助。

答案 1 :(得分:0)

在Rstudio上:

  1. 转到左上角的文件。

  2. 选择带有编码的保存

  3. 选择UTF-8

对所有R脚本(server.R / app.R)执行此操作

这对我有用。

答案 2 :(得分:0)

我也遇到了同样的错误。我意识到发生这种情况是因为有一个无与伦比的开括号。您可以转到顶部栏菜单上的“代码”,然后选择“显示诊断(项目)”以找出在哪一行中有一个中括号。 希望这会有所帮助。