Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The cause of "bad magic number" error when loading a workspace and how to avoid it?

I tried to load my R workspace and received this error:

Error: bad restore file magic number (file may be corrupted) -- no data loaded In addition: Warning message: file ‘WORKSPACE_Wedding_Weekend_September’ has magic number '#gets'    Use of save versions prior to 2 is deprecated  

I'm not particularly interested in the technical details, but mostly in how I caused it and how I can prevent it in the future. Here's some notes on the situation:

  1. I'm running R 2.15.1 on a MacBook Pro running Windows XP on a bootcamp partition.
  2. There is something obviously wrong this workspace file, since it weighs in at only ~80kb while all my others are usually >10,000
  3. Over the weekend I was running an external modeling program in R and storing its output to different objects. I ran several iterations of the model over the course of several days, eg output_Saturday <- call_model()
  4. There is nothing special to the model output, its just a list with slots for betas, VC-matrices, model specification, etc.
like image 200
N Brouwer Avatar asked Sep 17 '12 16:09

N Brouwer


People also ask

What does bad restore file magic number mean in R?

Unfortunately, the error “bad restore file magic number (file may be corrupted) — no data loaded” was returned. The reason for this is that the load function is not suited for rds files.

What does magic number mean in R?

The magic number comes from UNIX-type systems where the first few bytes of a file held a marker indicating the file type. This error indicates you are trying to load a non-valid file type into R. For some reason, R no longer recognizes this file as an R workspace file.


1 Answers

I got that error when I accidentally used load() instead of source() or readRDS().

like image 148
Chris SH Avatar answered Sep 22 '22 02:09

Chris SH