0

I am trying to write a dataframe to csv file, where I am getting the below error:

Warning in file (file, ifelse(append, "a", "w")): cannot open file '_______________.csv': Permission denied.
Warning: Error in file: cannot open the connection

Here is the script:

    input_fileName = file.path(s_input, paste0("input_1", now_1, ".csv"))
    
    dataframe_1=data.frame(g=unlist(strsplit(gsub(", +", ",", gsub("\\s+", ",", input$gid)), ',')),     start_date = input$start_d, end_date = input$end_d, 0, 0, 0, 0)
    
    write.table(
      x = dataframe_1,
      file = input_fileName,
      row.names = FALSE,


      col.names = FALSE,
      quote = FALSE,
      sep = ','
    )

The error is raised at write.table(). I tried reading the file, but the same error has raised there. How to resolve this?

r2evans
  • 141,215
  • 6
  • 77
  • 149
PikaPika
  • 9
  • 3
  • 1
    What is the value of `input_fileName`? Does that path exist? Do you have permission to write to that path? Is this part of some `shiny` app? Are you trying to write the file on the server or the client computer? – MrFlick Jan 30 '23 at 19:31
  • It's shiny app. Writing the file on the client computer. – PikaPika Jan 30 '23 at 19:54
  • Is the client also running the shiny app? Because shiny apps run in a server/client setup. Normally the server can't access the file system of the client directly. Things only get a bit different when you are running the shiny app completely on your own computer and no one else can access it. Is that the scenario you are currently it? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Jan 30 '23 at 20:11

0 Answers0