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

后端 未结 9 1280
自闭症患者
自闭症患者 2020-11-29 05:54

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 m         


        
9条回答
  •  既然无缘
    2020-11-29 06:22

    I got the error when building an R package (using roxygen2)

    The cause in my case was that I had saved data/mydata.RData with saveRDS() rather than save(). E.g. save(iris, file="data/iris.RData")

    This fixed the issue for me. I found this info here

    Also note that with save() / load() the object is loaded in with the same name it is initially saved with (i.e you can't rename it until it's already loaded into the R environment under the name it had when you initially saved it).

提交回复
热议问题