title: Create data with function inside shinyServer to feed ggplot
body: <p>I have a Shiny app what calculates some power estimates for a type of genetic association study. The ui.R is pretty simple, and the server.R has a function that gives a data frame (I think I can't have this function as <code>reactive</code> because it has some parameters).</p>
  
  <p>The link to the Gist is <a href="https://gist.github.com/aurora-mareviv/5895082" rel="nofollow">here</a>. To run it: </p>
  
  <pre><code>library(shiny)
  shiny:: runGist('5895082')
  </code></pre>
  
  <p>The app calculates correctly the estimates, but I have two questions regarding it:</p>
  
  <ul>
  <li><p>Is it possible to have the <code>output$powTable</code> actually represent all the values contained within the range, in the first <code>sliderInput(n.cases)</code>?. It only seems to represent the two extreme values of the range... what I'm doing wrong?</p></li>
  <li><p>There's an error when running the app: </p>
  
  <p><code>Error: Reading objects from shinyoutput object not allowed.</code></p></li>
  </ul>
  
  <p>How can I pass the data (reactivity?) from the function <code>f()</code> to feed the ggplot? After much trial and error, I am very lost. Where can be the error in my code? Many thaks in advance!</p>
  
  <p>The original code of the function works well: (EDITED)</p>
  
  <pre><code> f &lt;- function(ncases, p0, OR.cas.ctrl, Nh, sig.level) {
  num.cases &lt;- ncases
  p0 &lt;- p0
  Nh &lt;- Nh
  OR.cas.ctrl &lt;- OR.cas.ctrl
  sig.level &lt;- sig.level
  # Parameters related to sig.level, from [Table 2] of Samuels et al.
  # For 90% power and alpha = .05, Nscaled = 8.5
      if (sig.level == 0.05){
  A &lt;- -28 # Parameter A for alpha=.05
  x0 &lt;- 2.6 # Parameter x0 for alpha=.05
  d &lt;- 2.4 # Parameter d for alpha=.05
      }
      if (sig.level == 0.01){
  A &lt;- -13 # Parameter A for alpha=.01
  x0 &lt;- 5 # Parameter x0 for alpha=.01
  d &lt;- 2.5 # Parameter d for alpha=.01
      }
      if (sig.level == 0.001){
  A &lt;- -7 # Parameter A for alpha=.001
  x0 &lt;- 7.4 # Parameter x0 for alpha=.001
  d &lt;- 2.8 # Parameter d for alpha=.001
      }
      out.pow &lt;- NULL # initialize vector
  for(ncases in ncases){
      OR.ctrl.cas &lt;- 1 / OR.cas.ctrl # 1. CALCULATE P1 FROM A PREDEFINED P0, AND A DESIRED OR
      OR &lt;- OR.ctrl.cas
      bracket.pw &lt;- p0 / (OR - OR*p0) # obtained after isolating p1 in OR equation [3].
      p1 &lt;- bracket.pw / (1 + bracket.pw)
      Nh037 &lt;- Nh^0.37 # 2. CALCULATE NSCALED
      num.n &lt;- num.cases*((p1-p0)^2)
      den.n &lt;- (p1*(1-p1) + p0*(1-p0))*Nh037
      Nscaled &lt;- num.n/den.n
      num.power &lt;- A - 100 # 3. CALCULATE POWER
      den.power &lt;- 1 + exp((Nscaled - x0)/d)
      power &lt;- 100 + (num.power/den.power) # The power I have to detect a given OR with my     data, at a given alpha
      }
  OR &lt;- OR.cas.ctrl
  out.pow &lt;- data.frame(num.cases, Nh, Nscaled, p0, OR, sig.level, power)
  out.pow
  } 
  
  mydata &lt;- f(ncases=seq(50,1000, by=50), 0.4, 2.25, 11, 0.05)
  mydata
  
  library(ggplot2)
  print(ggplot(data = mydata, aes(num.cases, power)) +
  theme_bw() +
  theme(text=element_text(family="Helvetica", size=12)) +
  labs(title = "Ad-hoc power for haplogroup") +
      scale_color_brewer(palette = "Dark2", guide = guide_legend(reverse=TRUE)) +
  xlab("number of cases/controls") +
  ylab("power") +
  scale_x_log10() +
  geom_line(alpha=0.8, size=0.2) +
  geom_point(aes(shape = factor(OR)), colour="black"))
  </code></pre>