Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在sendSweetAlert中插入其他信息_R_Shiny - Fatal编程技术网

在sendSweetAlert中插入其他信息

在sendSweetAlert中插入其他信息,r,shiny,R,Shiny,我想在我的代码消息警报中包括将被排除在外的行业。这可能吗?在下面的可执行代码中,我制作了一个“output$ind”,显示了将被排除的行业。但是,我也想将此信息插入到我创建的消息警报中 library(shiny) library(rdist) library(geosphere) library(tidyverse) library(shinyWidgets) library(shinythemes) function.cl<-function(df){ #database df

我想在我的代码消息警报中包括将被排除在外的行业。这可能吗?在下面的可执行代码中,我制作了一个“output$ind”,显示了将被排除的行业。但是,我也想将此信息插入到我创建的消息警报中

library(shiny)
library(rdist)
library(geosphere)
library(tidyverse)
library(shinyWidgets)
library(shinythemes)

function.cl<-function(df){

  #database df
  df<-structure(list(Industries = c(1,2,3,4,5,6,7), 
                     Latitude = c(-23.8, -23.8, -23.9, -23.9, -23.9,-23.4,-23.5), 
                     Longitude = c(-49.8, -49.3, -49.4, -49.8, -49.6,-49.3,-49.1), 
                     Waste = c(526, 350, 526, 469, 285, 433, 456)), class = "data.frame", row.names = c(NA, -7L))


  coordinates<-subset(df,select=c("Latitude","Longitude")) 
  d<-distm(coordinates[,2:1]) 
  diag(d)<-1000000 
  min_distancia<-as.matrix(apply(d,MARGIN=2,FUN=min))
  limite<-mean(min_distancia)+sd(min_distancia) 


  search_vec <- function(mat, vec, dim = 1, tol = 1e-7, fun = all)
  which(apply(mat, dim, function(x) fun((x - vec) > tol)))
  ind_exclude<-search_vec(min_distancia,limite,fun=any)
  if(is_empty(ind_exclude)==FALSE){
  for (i in 1:dim(as.array(ind_exclude))){
  df<-subset(df,Industries!=ind_exclude[i])}}


   return(list(
    "IND" =  ind_exclude
  ))

}

ui <- bootstrapPage(
  navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
             "Cl", 
             tabPanel("Solution",
                      sidebarLayout(
                        sidebarPanel(

                          h4("The excluded industries are:"),
                          tableOutput("ind"),

                          selectInput("filter1", h3("Select farms"),
                                      choices = list("All farms" = 1, 
                                                     "Exclude farms" = 2),
                                      selected = 1),


                          ),
                        mainPanel(
                          tabsetPanel())))))  

server <- function(input, output, session) {

  Modelcl<-reactive({
    function.cl(df)
  })

  output$ind <- renderTable({
    IND <- ((Modelcl()[[1]]))
  })

  observe({
    if(input$filter1 == 2){
      sendSweetAlert(
        session = session,
        title = "Information!",
        btn_labels = c("Yes", "No"),
        text = tags$div(h5("The industries that need to exclude are:"), 

        ),

        type = "info"
      )
    }
  })


  }

shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(rdist)
图书馆(地球圈)
图书馆(tidyverse)
图书馆(shinyWidgets)
图书馆(shinythemes)

函数。cl好的,当然。您可以只包含您用于表格的相同无功值,不是吗

sendSweetAlert(
  session = session,
  title = "Information!",
  btn_labels = c("Yes", "No"),
  text = tags$div(h5("The industries that need to exclude are:", 
                     # just include the same information here
                     paste(Modelcl()[[1]], collapse = ", "))

  ),
  type = "info"
)

当然可以。您可以只包含您用于表格的相同无功值,不是吗

sendSweetAlert(
  session = session,
  title = "Information!",
  btn_labels = c("Yes", "No"),
  text = tags$div(h5("The industries that need to exclude are:", 
                     # just include the same information here
                     paste(Modelcl()[[1]], collapse = ", "))

  ),
  type = "info"
)
请,你能看一下吗