Write.csv and write.xlsx problems

Asked

Viewed 200 times

0

I use windows 64 bits, I have java installed and set the working directory in R. But, when running a simple code such as:

teste <- data.frame(a=c(2,2),b=c(3,3))
write.csv2(teste,file = "teste.csv")

I’m getting the following error:

Error in file(file, ifelse(append, "a", "w")) : 
  não é possível abrir a conexão
Além disso: Warning message:
In file(file, ifelse(append, "a", "w")) :
  não foi possível abrir o arquivo 'teste.csv': Permission denied

If I try to use the code:

library(xlsx)
write.xlsx(data2, file="data2.xlsx", col.names=TRUE, row.names=FALSE)

Obtenho:

Error in .jcall(cell, "V", "setCellValue", value) : 
  method setCellValue with signature ([Ljava/lang/String;)V not found
Além disso: Warning message:
In if (is.na(value)) { :
  a condição tem comprimento > 1 e somente o primeiro elemento será usado

Both codes worked on my machine, usually. They stopped working overnight. I’ve searched every possible page, reinstalled R and Rstudio, rebooted the machine, changed the files folder. I don’t know how else to do to solve this! Someone has been through similar problem and can help me?

  • It looks like a problem with the java call, make sure your machine has JDK installed as you cite the package documentation: https://www.rdocumentation.org/packages/xlsx/versions/0.6.3

  • As Lucas said it looks like a problem with Java, which system do you use? Are you saving in which directory? Java is installed?

  • 3

    Are you running R where? Have you set the working directory? You have write permission for it?

  • I am running windows, yes I have Java installed. The working directory has been set, I have full permission to write to it!

  • Are you setting the file path correctly? Because using R in windows you have to pass the path with / and not with . Example: C: so it doesn’t work but so it works: C:/

  • I’m setting it correctly, I’ve done it a million times. As I said, I’ve researched every possible forum, I can’t understand this mistake! There are many people with the same problem! I hope that those who gave "downvote" the question never face the same problem!

  • 1

    I also didn’t understand the down vote on the question.But from this site I don’t doubt anything. There are people who copy their solution, put on top and still take credit. Give of everything here

Show 2 more comments

1 answer

1

Apparently it was the antivirus Avast that was causing the problem. I disabled it for 10 min and reinstalled the xlsx package. I rebooted the R and after 24 hours lost, I was able to make it work again! I hope that more people solve the problem with the same solution, after a huge search on the internet, I found that many have asked this same question!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.