Error: Error in libxlsxwriter: 'Error creating output xlsx file. Usually a permissions error.

Hi,

I have a file data (read count data) that I transformed into IHST as follows:

my_asinh <- function(var) { var_ihs = log(var + sqrt(var^2+1)); return(var_ihs) }
x_ihs = my_asinh(dat)
head(x_ihs)

Then, I want to export it as xslx using the following code:

write_xlsx(x_ihs, "/home/Documents/family/data_family_iht.xlsx")

But I got this error:
[ERROR] workbook_close(): Error creating '/home/Documents/family/data_family_iht.xlsx'. System error = No such file or directory
Error: Error in libxlsxwriter: 'Error creating output xlsx file. Usually a permissions error.'

Same when I exported as csv:
write.csv(x_ihs, file="/home/Documents/family/data_family_iht.csv")
I got this error:

Error in file(file, ifelse(append, "a", "w")) : cannot open the connection

  1. file(file, ifelse(append, "a", "w"))

  2. utils::write.table(x_ihs, file = "/home/Documents/family/data_family_iht.csv", col.names = NA, sep = ",", dec = ".", qmethod = "double")

  3. eval(expr, p)

  4. eval(expr, p)

  5. eval.parent(Call)

  6. write.csv(x_ihs, file = "/home/Documents/family/data_family_iht.csv")

However, I have successfully used these codes before.

N.B. R and RStudio are installed on Ubuntu 20.04.

Any suggestions or help!

Thanks!

What is the context in which the write calls occur? Are you in a console, an R script in RStudio, a markdown document, a Shiny app or what?

Markdown chunks in RStudio console!

Shouldn't the filepath have a username of some sort between /home and documents? Something to the effect of /home/Eman/Documents/family... for a Linux system?

Best,
Randy

Yes, there is a username that includes the lab information, so I removed it from the path before posting the issue on the forum.

1 Like

In that case, I would guess you have a Linux permissions error as the original error message indicates. Did you create the family folder with the username you are currently using? Similarly, if you change the directory to just /home/<username>, can you write there?

I already have the right path in my code, but I do not know how to fix the Linux permissions error.
Your assistance is much appreciated!

What do you get if you run ls -ltr at the terminal for the directory in question? You should get something similar to this:

total 0
drwxr-xr-x+  4 randyzwitch  staff   128 Jan  5 17:07 Public
drwx------+  3 randyzwitch  staff    96 Jan  5 17:07 Documents
drwx------+  4 randyzwitch  staff   128 Jan  5 17:07 Pictures
drwx------   4 randyzwitch  staff   128 Jan  5 17:40 Movies
drwx------+  4 randyzwitch  staff   128 Jan 16 08:25 Music
drwx------@ 91 randyzwitch  staff  2912 Mar 15 09:35 Library
drwxr-xr-x  17 randyzwitch  staff   544 Jun 13 08:34 miniconda3
drwxr-xr-x  10 randyzwitch  staff   320 Jun 14 11:08 github
drwx------+ 74 randyzwitch  staff  2368 Jun 17 11:16 Downloads
drwx------+ 13 randyzwitch  staff   416 Jun 17 11:16 Desktop

Or if you are in a GUI environment, what does it look like if you right-click and go to permissions?

Hello,

I ran it and get:
total 959920
then a long list of drwxr-xr-x , -rw-rw-r--,.....

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.