-5

I have a R script that reads files and generates graphs automatically. It works when it runs the first time. If the .png files are there and the script needs to re-create them with the new data, I get this error:

Error: bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file 'test1.png' has magic number 'ëPNG'
   Use of save versions prior to 2 is deprecated
Execution halted

what does this error mean? I tried to use source("filename"), it did not work either.

thanks,

Sean Kaplan
  • 61
  • 2
  • 9
  • 1
    you're trying to load a `png` file and not an `RData` file ... (or you've overwritten your R data files with PNGs ...) – Ben Bolker May 29 '12 at 21:29
  • I am trying to generate png files like this: png(paste(x$var1,x$var,".png",sep=""), height=850, width=750) I see in the name of the file that there is a space before the .png. Do you think this is causing it? – Sean Kaplan May 29 '12 at 21:35
  • 6
    no. The error message is fairly specific and diagnostic in this case -- you are asking R to `load()` a file called `test1.png`, and, unsurprisingly, it's not in RData format. This kind of piecemeal remote debugging is going to get very frustrating for everyone ... try reading http://tinyurl.com/reproducible-000 and see if you can reduce your problem to something short and replicable that you can post here (in the process you're likely to discover your problem for yourself) – Ben Bolker May 29 '12 at 21:38
  • you are right. I used setwd to change the directory of the saved images, it worked. hurrayy. – Sean Kaplan May 29 '12 at 21:54

1 Answers1

2

I had to split the directories that I was working with. I am outputting to another folder as below resolves the problem.

setwd("C/img")

Sean Kaplan
  • 61
  • 2
  • 9
  • Also, why is this post down voted. I have never seen that error and couldn't find much resources to help with that error. I am learning R and I am amazed by it everyday. I participate in this site a lot and down voting my post does not help anything. – Sean Kaplan May 30 '12 at 15:45
  • I dont understand why this post was down voted. What does that error message mean? It is not descriptive. I know some of you are familiar with R and have been around. Bur for a new bie, that error message does not mean anything. Now it does mean something to me and if I see it again, I will definetely know. Also, if anybody new to R and saw that error, this post will help them greatly. Please if you cant contribute in a positive way, stop contributing at all. The purpose of this site is to collaborate not destroy -- at least I hope. – Sean Kaplan May 31 '12 at 13:23
  • @Andrei, your closing and down voting my post did not help anything. My account is blocked and cannot post anything on this site. Congradulations!! – Sean Kaplan Jun 18 '12 at 15:53