I am doing a loop on different file and need to read a file extract the information and then delete it.
In R I use the package
datatemp = openxlsx::read.xlsx(xlsxFile = "./source/aFile.xlsx")
However I can’t remove the file from windows, it tells me it is open in R studio, I tried to point read.xlsx to another file, and to
closeAllConnections but it did not work.
Is there a way to disconnect R from the file without having to close R studio ?
I am on Windows 7 and I used
unlink which let me delete the file
datatemp = openxlsx::read.xlsx(xlsxFile = "temp.xlsx") unlink(datatemp)
Then I was able to manually delete the file without a problem