Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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
Javascript 闪亮的标题(导航栏),带有一些按钮,而不是选项卡_Javascript_Html_R_Shiny - Fatal编程技术网

Javascript 闪亮的标题(导航栏),带有一些按钮,而不是选项卡

Javascript 闪亮的标题(导航栏),带有一些按钮,而不是选项卡,javascript,html,r,shiny,Javascript,Html,R,Shiny,我想创建一个闪亮的应用程序,它有一个标签导航栏,导航栏有一个徽标和一些下载按钮。我曾经使用HTML创建按钮,但我希望onClick函数与我作为output$downloadData包含的按钮相同。是否可以混合搭配R代码和JS,使导航栏中的按钮成为下载按钮 library(shiny) # Define UI for application that draws a histogram ui <- navbarPage( # Application title "Old Fa

我想创建一个闪亮的应用程序,它有一个标签导航栏,导航栏有一个徽标和一些下载按钮。我曾经使用HTML创建按钮,但我希望onClick函数与我作为
output$downloadData
包含的按钮相同。是否可以混合搭配R代码和JS,使导航栏中的按钮成为下载按钮

library(shiny)

# Define UI for application that draws a histogram
ui <- navbarPage(

   # Application title
   "Old Faithful Geyser Data",

   # Sidebar with a slider input for number of bins 

      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ), 

      # I included download buttons here for functionality,
      # these are the buttons I'd like in the top right
      # Can I use onclick=downloadData or something within my HTML?
      mainPanel(
        downloadButton("downloadData", "CSV"),
        downloadButton("downloadData2", "TXT"),
         tableOutput("dist")
      ),


   # Can I add R code to the HTML code so that onclick
   # by button uses output$Downloaddata below?
   tags$script(HTML("var header = $('.navbar> .container-fluid');
                   header.append('<div style=\"float:right; valign:middle\"><button onClick=downloadCSV(); style=\"valign:middle;\">Download CSV</button><button>Download SAS</button></div>');
                    console.log(header)"))
)

# Define server logic required to draw a histogram
server <- function(input, output) {

  dummy <- data.frame(x = c(1,2,3), y = c(4,5,6))

   output$dist <- renderTable({
     dummy
   })

   output$downloadData <- downloadHandler(
     filename = function() {
       paste(dummy, ".csv", sep = "")
     },
     content = function(file) {
       write.csv(dummy, file, row.names = FALSE)
     }
   )

   output$downloadData2 <- downloadHandler(
     filename = function() {
       paste(dummy, ".csv", sep = "")
     },
     content = function(file) {
       write.csv(dummy, file, row.names = FALSE)
     }
   )

}

# Run the application 
shinyApp(ui = ui, server = server)
库(闪亮)
#为绘制直方图的应用程序定义UI
ui.容器(液体);
append('Download CSVDownload SAS');
console.log(标题“”)
)
#定义绘制直方图所需的服务器逻辑

服务器不能执行类似于
header.append($('#downloadData'))
的操作吗?你让我大吃一惊-谢谢!!