Problem with opening .sdf file on Shiny

29 views
Skip to first unread message

saura...@shiats.edu.in

unread,
Apr 23, 2017, 4:50:34 AM4/23/17
to Shiny - Web Framework for R
Dear All,

I am trying to upload structure-data file on shiny server using fileInput function in ui.R.
I wish to analyse the uploaded file using another package viz. ChemmineR and the resultant I want again to print on browser.


###############################################################
#My ui.R
library("shiny")
library("ChemmineR")

shinyUI(fluidPage(
  titlePanel("SDF input"),
  sidebarLayout(
    sidebarPanel(
      fileInput("file1", "Browse")
    ),
    mainPanel(dataTableOutput('ofile'))
    
)))

#My server.R
library("shiny")
library("ChemmineR")

shinyServer(function(input,output){
  
  data <- reactive({
   
   read.SDFset(sdfstr=input$file1)
      })


  output$ofile<- renderDataTable(data())
})

#My console
> runApp('C:/Users/saurav/Dropbox/office/Saurav_Saha_SHIATS/Chemoinformatics_uCARE/analysis/drug_class_based_Classification/r_scripts/web_gui/test')

Warning: Error in seq: trying to get slot "a" from an object of a basic class ("NULL") with no slots
Stack trace (innermost first):
    94: seq
    93: lapply
    92: read.SDFset
    91: <reactive:data> [C:\Users\saurav\Dropbox\office\Saurav_Saha_SHIATS\Chemoinformatics_uCARE\analysis\drug_class_based_Classification\r_scripts\web_gui\test/server.R#8]
    80: data
    79: renderDataTable
    78: func
    77: origRenderFunc
    76: output$ofile
     1: runApp

#################################################

Please help. Thanks in advance,

Saurav


server.R
ui.R

Bárbara Borges

unread,
Apr 24, 2017, 10:49:30 AM4/24/17
to Shiny - Web Framework for R
Can you open the same file (using the same function) from the console? If you can't, then Shiny is not the problem. If you can, then please send along the file, and I can try to see if it's a problem in Shiny.

Bárbara Borges

unread,
Apr 24, 2017, 10:58:31 AM4/24/17
to Shiny - Web Framework for R
Although just looking at your code, I also noticed you're not using fileInput() correctly. To get the datapath on the server, you should call input$file1$datapath, as demoed in the documentation (?fileInput):

output$contents <- renderTable({

    # input$file1 will be NULL initially. After the user selects

    # and uploads a file, it will be a data frame with 'name',

    # 'size', 'type', and 'datapath' columns. The 'datapath'

    # column will contain the local filenames where the data can

    # be found.

    inFile <- input$file1


    if (is.null(inFile))

      return(NULL)


    read.csv(inFile$datapath, header = input$header)

  })

saura...@shiats.edu.in

unread,
Apr 25, 2017, 12:43:10 PM4/25/17
to Shiny - Web Framework for R
Thanks Barbara for your help,

With some help, I was able to do the sdf reaching.
The code is attached herewith this post.

Regards,
Saurav
sdf.R
Reply all
Reply to author
Forward
0 new messages