Link to home
Start Free TrialLog in
Avatar of Daniele Questiaux
Daniele QuestiauxFlag for Australia

asked on

Cannot open a result file in R with message permission denied.

I have received some code in R but when I run the code, I get the the following message at the end
Error in file(file, ifelse(append, "a", "w")) :
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'ptr.txt-3R.res': Permission denied
There is therefore a result file, but it cannot be opened!
I am supposed to get graphs as well as results, but I only get some results with no graphs which is suspect need to access the result file?
Why would it not be able to access the result file?
I am totally novice in R and rally lost as this code works perfectly in one of my colleagues desktop!
Thanks!
Danièle
Avatar of oheil
oheil
Flag of Germany image

Can you provide the line of code where you try to open the file ?

Oli
Avatar of Daniele Questiaux

ASKER

Hi Oli!

I looked through the code, and I can see where it write the filenam-.res file ( "filenam" being the name of the input file), but I cannot find where it needs to open it, presumably for the plotting of the results?

This is a code I received and it works on other computers. I loaded the R program as an administrator to ensure no permissions problems.

The code asks me to give the file name and one value, then the whole process goes to completion with three graphs and a result file.
The result file cannot be opened with permission denied but I am not sure why it needs to open that file as it is a simple text file with the results. I am not sure whether it wants to open it to show the results. Three graphs should normally be produced but they do not appear.
I am concerned about that "permission denied". This is on my own computer so there is no IT restriction.
I am also wondering why I cannot get the graphs either.
I am using R-3.0.2.
When I run it with R studio, I do not get that message and it runs to completion, but there are again no graphs appearing!
I hope you can make sense out of this very frustrating "denied access".
Thanks!
Danièle
ptr.txt-3R.res
code1.txt
ASKER CERTIFIED SOLUTION
Avatar of oheil
oheil
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!

That is a lesson I wil remember!
The code and the file where n different folders.
 I would use the File>source R(code) to get the code, but it was in a different folder than the file which was in the folder I had set via the File> change dir. OK, the source code and the files need to be together!

For the .ps file, is there a way for me to add a line of code so they could be displayed?
I will start a new thread for that one
:)
Many many thanks! This was driving me mad.

Danièle

PS I use windows 8.
I also installed R-2.14-1 and had had the same issue as with R-3.0.1, but of course, it now works perfectly well.
R is fun to work with, but unforgiving.

Any code not from a package needs to be placed in a working directory together with any file or data you will work with. Simple but not altogether an obvious requirement!

Thanks!
Code and Data must not be in the same directory. When you start R, it may in some working directory, which is not suitable to save data. So, the acual working directory was your problem. When I start R (Windows 7) I am in "C:/Windows/system32". You can print it with getwd().
Putting all together was just to reduce any effects which may be the cause of your problem.

You could link your new question here, so I can find it easily :-)

Oli