title: Access dataframe in .Rdata from Shiny
body: <p>I have a small shiny program below which reads in an .Rdata file using Shiny. The code below works as expected, but there is behavior that I desire that I cannot quite figure out how to implement from within Shiny.</p>
  <p>To frame the first problem, suppose I have a file called tmp.Rdata and when that .Rdata is loaded into the R workspace it contains a data frame called &quot;foo&quot;. My objective is to load the .Rdata using shiny and then access the data frame within it (foo) and do R things to it.</p>
  <p>For example, if I was working within R proper, my actions would be something like:</p>
  <pre><code>&gt; load('tmp.Rdata')
  &gt; str(foo)
  </code></pre>
  <p>And supposing foo is a data frame with K columns, the result of str(foo) would show the typical behavior of str() on the object.</p>
  <p>When implementing the code below, the Shiny program runs and I can see the .Rdata loads successfully and that &quot;foo&quot; is in the workspace. However, the resulting action from str() in this instance is to show that the object foo is in the workspace, not the structure of the object foo itself, which is the behavior I want to implement.</p>
  <pre><code>chr &quot;foo&quot;
  </code></pre>
  <p>Now, if I know ahead of time that the .Rdata will always have in it a frame called &quot;foo&quot; I could hard code this into the server.R code and all is well. But, the more challenging problem is that my users will save an .Rdata file that contains within it a data frame with an unknown name.</p>
  <p>I have searched SO and found similar questions, but not exactly tackling the same problem as far as I can tell, such as the one at the link below</p>
  <p><a href="https://stackoverflow.com/questions/33071712/loading-user-input-rdata-on-shiny-app">Loading User input .Rdata on Shiny App</a></p>
  <p>Thank you for any suggestions.</p>
  <h1>ui.R</h1>
  <pre><code>shinyUI(fluidPage(
    titlePanel(&quot;Uploading Files&quot;),
    sidebarLayout(
      sidebarPanel(
       h4(&quot;Uploading Files&quot;),
       fileInput('f1', 'Choose RData File', accept=c('.RData, .Rds'))
      ),
      mainPanel(
       h4(&quot;Data Structure&quot;),
       verbatimTextOutput(&quot;datastr&quot;)
      )
    )
  ))
  </code></pre>
  <h1>server.R</h1>
  <pre><code>shinyServer(function(input, output) {
  dataInput &lt;- reactive({
    sessionEnvir &lt;- sys.frame()
      if (!is.null(input$f1)) load(input$f1$datapath, sessionEnvir)
    })
    output$datastr &lt;- renderPrint({
    ff &lt;- dataInput()
      if (is.null(dataInput()))  return()  else str(ff)
    })
  })
  </code></pre>