0

EDIT: Thanks for your help guys. The issue has now been resolved. The "local" attribute had to be turned on for data to pass between the different environment:

source("compute.R", echo = TRUE,local=T)

I know similar questions have been asked before, but none of the advise is working for me. I need to create a data frame from user inputs which will be further used by functions following the creation of the data frame. The code is below:

        shinyServer(function(input,output,session){

              output$table<-renderTable({ 
                input$goButton
                condoname<-reactive({input$Condo_Name})
                floorno<-reactive({input$Floor_no})
                inputdate<-reactive({input$Date})
                datefilter<-as.Date(inputdate(),"%Y-%m-%d")
   user_data<-data.frame(condoname=condoname(),floorno=floorno(),datefilter=datefilter)
                user_data
    })
    })

The data frame is never formed and I get a 'object user_table not found' in an error message. Its quite frustating because I'm sure I'm missing something very simple. Any help will e appreciated. Thanks!!!

Edited to add:

UI:
#install.packages("shiny")
library(shiny)


shinyUI(fluidPage(

    fixedRow(
     column(3,selectInput("Condo_Name",
                          label=("Select Condo Name"),
                          choices=as.list(c("Condo1","Condo2")),
                          selected=1)),
     column(3,selectInput("Floor_no",
                          label=("Floor"),
                          choices=as.list(c("1","2")),
                          selected=1)),
     column(3,offset=3,row=-1,dateInput("Date",
                          label=("Date"),
                          value="2006-01-03",
                          max="2015-10-01"

                          )), 
     column(4,offset=3,             
            submitButton("Submit")),
    mainPanel(
             "Table", tableOutput("table"),style = "font-weight: 500; line-height: 1.1; 
        color: #4d3a7d;")



      )
    )
  ))
UD1989
  • 307
  • 1
  • 14
  • Can you post a link to full code of the app (UI + server), or at least shortened example with, say, just 1-2 inputs from the above list, so we can play around with it on local machine? – Jakub P. Jul 15 '15 at 10:08
  • Hi @JakubP. Thanks for your response. I've added the shortened version...should help you unerstand. Thanks – UD1989 Jul 15 '15 at 10:30
  • Remove the backticks in line that starts with `user_data` (one at the beginning, one at the end). When I did that, the app runs fine, and datatable is shown properly with inputs. Exact code I used is [on this R fiddle](http://www.r-fiddle.org/#/fiddle?id=3pZ9vlsg&version=1). – Jakub P. Jul 15 '15 at 11:58
  • Also there's a missing quote " in `datefilter<-as.Date(inputdate(),"%Y-%m-%d)` – Jakub P. Jul 15 '15 at 11:59
  • @JakubP. Hmm...Thanks for your help...Those weren't the problem though.....actually I am calling another source file in the server.R ( using source(filename.R) to do some calculations......which uses the 'user_data' dataframe. Apparently it is not being passed on to this source file ....any idea how to do that? Thanks – UD1989 Jul 15 '15 at 12:25
  • Include source("your_file") in server.R – Shiva Jul 15 '15 at 12:38
  • I'm not sure how your data flows between `shinyServer()` call and that other script. How do you pass `user_data` object (created in server.R above) to that external script? Do you call `someFunc(user_data)` in server.R somewhere? Because I don't see it anywhere here. – Jakub P. Jul 15 '15 at 12:38
  • @JakubP. Yes I call function which parses another source code. My question is exactly that- **"How do you pass user_data object (created in server.R above) to that external script?"** Unfortunately i cannot share all the code here since some of it is kinda proprietary to my company – UD1989 Jul 15 '15 at 12:54
  • 1
    Try creating a reproducible example.http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Because it helps you and others to understand your problem. – Shiva Jul 15 '15 at 13:14
  • 1
    @UD1989 I +1 Shiva's comment above. I think it's relatively easy to help you once we get the full picture. The data frame _is_ created, however it's done inside the server process (and visualized in the UI as data table). If you need the external script to use it, make that external script into a function (`someFunc <- function(my.df) { ALL YOUR CODE HERE WHICH USES my.df }`), source it inside `server.R`, and inside renderTable(..) call at the end call that function someFunc(user_data) ). If that's not what you're after, we need the full example. – Jakub P. Jul 15 '15 at 13:48

0 Answers0