Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button submit R with shiny

I'm trying to implement a form to upload a file, but start to do operation when I click on a submit button, the problem is that a have a strange mistake and I don't know what's it, I made the example of the tutorial and it worked without problem, now I'm implementing the same but with index.html and it don't work.

The mistake is: "Error in if (input$uploadFasta == 0) return(NULL) : argument is of length zero"

my index.html is like:

<form class="span12 menu-med-upload">
    <div class="row-fluid">
        <center>
          <div class="custom-input-file btn btn-inverse">
            <input type="file" size="1" id="fileFasta" class="input-file" />
          </div>
        </center>
        <button id="uploadFasta" type="button" class="btn action-button shiny-bound-input" >go!</button>
    </div>
</form>

my server.R is like:

output$table <- renderText({
    if(input$uploadFasta == 0)
        return(NULL)
    myRenderTable()
})

somebody know what's the problem, and thank for all and sorry if this topic was open before but I could not find.

like image 867
user2029940 Avatar asked Nov 04 '22 01:11

user2029940


1 Answers

Action button is a custom input binding and I'll bet it's not being loaded.

Add a global.R file in the same directory as server.R, and have it contain this:

addResourcePath(
    prefix='actionbutton', 
    directoryPath=system.file('actionbutton', 
                          package='shinyIncubator'))

Then in your index.html, add the following to <head>:

<script src="actionbutton/actionbutton.js"></script>

(As always, be sure to have an explicit closing </script> tag--don't use <script />.)

like image 101
Joe Cheng Avatar answered Nov 12 '22 19:11

Joe Cheng