闪亮的应用程序:发生错误。检查您的日志或联系应用作者以进行澄清

时间:2019-12-23 11:27:03

标签: r shiny shiny-server shiny-reactivity shinyapps

我试图与ShinyApps IO共享我的Shiny应用程序,当我尝试从另一台计算机上使用我的应用程序时遇到以下问题。

我一直在阅读有关路径问题的信息,但是我认为代码中没有问题。

也许软件包有一些问题,但我不知道。



library(shiny)
library(dplyr)



time.series3<- function(df, date1, date2, resultats, var,week){

  codi_assig <- df$X_id[1] 
  df$Date <- as.Date(df$Date)
  date1 <- as.Date(date1)
  date2 <- as.Date(date2)
  week1 <- format(date1, format="%Y-%U")
  week2 <- format(date2, format="%Y-%U")



  time <- seq(date1,date2, by = 1)

  if(resultats == 1){

    if( var %in% names(df)){



    if(week == TRUE){



      df$week <-  format(df$Date, format="%Y-%U")

      df2 <- df

      AccionsP2 <- df2 %>% select( total_acccions, starts_with('mod'))


      AccionsP2$week <- format(df2$Date, format="%Y-%U")


      week <- aggregate(. ~ week, AccionsP2, sum)

      week <- cbind(week, aggregate(cbind(Usuaris_actius, enrollements) ~ week, df, max))

      as.Date(week$week, format = "%Y-%U")

      p <- barplot(week[week$week >= week1 & week$week <= week2,][[var]], names.arg = week[week$week >= week1 & week$week <= week2,]$week, cex.names = 0.75, las = 2, ylab = var, font.lab = 2, 
                   col = "lightblue", ylim = c(0,20 + max(week[week$week >= week1 & week$week <= week2,][[var]])), main = codi_assig, xlab = "Setmana")

      return (p)



    }else{
      #TIMESERIE




      p <- plot(df[df$Date %in% time,]$Date, df[df$Date %in% time,][[var]], type = "l", lwd = 4, las = 2, xlab = "Temps", ylab = var,
                col = "lightblue", main = codi_assig, font.lab = 2)

      return(p)

    }

    }else{

    }




  }else if (resultats == 2){
    if(week == TRUE){



      df$week <-  format(df$Date, format="%Y-%U")

      df2 <- df

      AccionsP2 <- df2 %>% select( total_acccions, starts_with('mod'))


      AccionsP2$week <- format(df2$Date, format="%Y-%U")


      week <- aggregate(. ~ week, AccionsP2, sum)

      week <- cbind(week, aggregate(cbind(Usuaris_actius, enrollements) ~ week, df, max))

      as.Date(week$week, format = "%Y-%U")

      enro <- max(df[df$Date %in% time,]$enrollements, na.rm=TRUE)

      p <- barplot((100/enro)*week[week$week >= week1 & week$week <= week2,][["Usuaris_actius"]], names.arg = week[week$week >= week1 & week$week <= week2,]$week, cex.names = 0.75, las = 2, ylab = "Percentatge Activitat", font.lab = 2, 
                   col = "lightblue", ylim = c(0,100), main = codi_assig, xlab = "Setmana")

      return (p)

    }else{


      #ACTIUS INSCRITS

      enro <- max(df[df$Date %in% time,]$enrollements, na.rm=TRUE) #ACABAR DE PERFILAR

      p <- plot(df[df$Date %in% time,]$Date, (100/enro)*df[df$Date %in% time,][["Usuaris_actius"]], type = "l", lwd = 4, las = 2, xlab = "Temps", ylab = "Percentatge Activitat",
                col = "lightblue", ylim = c(0,100), main = codi_assig, font.lab = 2)

      return(p)

    }

  }else{

    #RECURSOS

    AccionsP <- df[df$Date %in% time,] %>% select( starts_with('mod'))


    figure3 <- barplot(sort(100*(sapply(AccionsP, sum, na.rm = TRUE))/sum(df[df$Date %in% time,]$total_acccions,na.rm = TRUE),decreasing = TRUE),
                       ylim = c(0,100), col=blues9, main = paste("Principals Accions de ", codi_assig, sep = ""),  xlab = "Accions", ylab = "Percentatge", font.lab = 2)

    text(figure3 ,sort(100*(sapply(AccionsP, sum, na.rm = TRUE))/sum(df[df$Date %in% time,]$total_acccions, na.rm = TRUE), decreasing = TRUE)
         ,round(sort(100*(sapply(AccionsP, sum, na.rm = TRUE))/sum(df[df$Date %in% time,]$total_acccions, na.rm = TRUE), decreasing = TRUE)
                ,2),cex=1.1, pos = 3)

    return (figure3)

  }

}


server <- function(input, output){

  data <- reactive({
    file1 <- input$file    
    if(is.null(file1)){return()}
    read.table(file = file1$datapath,  header = TRUE, sep = ";")
  })


  output$Plot1 <- renderPlot({
    if(is.null(data())){return()}
    time.series3(data(), input$dateRange[1], input$dateRange[2], resultats= input$ResultatsType, var= input$Var, week = input$week)
  })
}

ui <- shinyUI(fluidPage(

  titlePanel(strong("Intefaz ICE: ATENEA")),

  sidebarLayout(
    sidebarPanel(

      fileInput("file", "Puja l'arxiu:"),  

      dateRangeInput(inputId = 'dateRange',
                     label = 'Interval de dades: yyyy-mm-dd',
                     start = Sys.Date(), end = Sys.Date(), format = "yyyy-mm-dd")



      ,radioButtons("week", "Dades per dia o per setmana: ", c("Per Dia"= FALSE,"Per Setmana"= TRUE))


      ,radioButtons("ResultatsType", "Tipus de Resultats: ", c("Serie Temporal"= 1,"Percentatge d'Activitat"= 2, "Recursos mes utilitzats"=3))


      ,selectInput("Var", "Variable:", 
                   choices=c("mod_assign", "mod_attendance", "mod_bigbluebuttonbn", "mod_book", 
                             "mod_chat", "mod_choice", "mod_choicegroup", "mod_data", "mod_feedback",
                             "mod_folder", "mod_forum", "mod_glossary", "mod_hvp", "mod_imgrecourse",
                             "mod_imscp", "mod_label", "mod_lesson", "mod_linklcms", "mod_lti", "mod_page",
                             "mod_quiz", "mod_resource", "mod_scorm", "mod_survey", "mod_url", "mod_wiki", "mod_workshop",
                             "total_acccions", "Usuaris_actius"))

    ),

    mainPanel(
      plotOutput("Plot1")
    )  )

)
)




shinyApp(ui = ui, server = server)

非常感谢!

0 个答案:

没有答案