0

I'm trying to readLines from a connection. Below is my code,

 server <- function(input,output, session) {   
  
  netlist <- reactive({
    netlistdata <- readLines('run.scs')
    print(netlistdata)
  })   
 }

  
 

I'm trying to display the lines of the file (run.scs) which is in the current working directory in the console. I'm not able to see any values or even errors when I use the above code.

r2evans
  • 141,215
  • 6
  • 77
  • 149
SSK
  • 59
  • 6
  • Without seeing more of the shiny server, it's hard to know for sure, but I find it odd that your function here can operate correctly. Is `simDev_func_v4_sblk` called from within `server`? Within some other `reactive` block? – r2evans Oct 07 '20 at 04:30
  • Actually simDev_func_v4_sblk function is called inside a module. The module is obviously called from the server. I do not want to complicate the code much by showing more. Only the readLines part is not working. All the other parts of the code are working fine. – SSK Oct 07 '20 at 04:58
  • 2
    `netlist` is defined but neither returned nor assigned to any environment. It will be discarded immediately after it is defined. And because it's `reactive` (as opposed to `observe`), it's lazy, so since nothing is dependent on it, its contents will never be called. – r2evans Oct 07 '20 at 05:07
  • I see. How do I assign netlist to an environment? – SSK Oct 07 '20 at 05:17
  • 1
    This isn't how shiny modules work. At the risk of sounding "rtfm"-esque (not my intent), have you read https://shiny.rstudio.com/articles/modules.html? A shiny module typically has one or two parts: a `ui` component and/or a `server` component. The `ui` component usually returns a `tagList`; the `server` component usually returns a `function` declaration. – r2evans Oct 07 '20 at 05:22
  • Yes I do know about modules. I have edited the code. What if I try to run the same code from server. I just need to read a file named (run.scs) which is in the working directory and display the lines of the file in the console. – SSK Oct 07 '20 at 05:29

0 Answers0