“bad restore file magic number” error in R

2019-05-06 15:18发布

As in What could cause a "bad magic number" error when loading an R workspace and how to avoid it? and R has magic number 'ëPNG' error, I'm getting a bad restore file magic number error:

> load("fossilien.dat")
Error: bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file ‘fossilien.dat’ has magic number '"Samp'
   Use of save versions prior to 2 is deprecated 

Using the source function gives me a different error (similar to unexpected string constant):

> source("fossilien.dat")
Error in source("fossilien.dat") : 
  fossilien.dat:1:10: unexpected string constant
1: "Sample" "Sname"
            ^

This is especially frustrating as I'm confident the source of data is legit - its for a homework problem: ftp://stat.ethz.ch/Teaching/Datasets/WBL/fossilien.dat

None of the SO questions above were really answered properly so I thought I would try again.

Some details about my R installation:

> R.Version()
$platform
[1] "x86_64-apple-darwin9.8.0"
$version.string
[1] "R version 2.15.3 (2013-03-01)"

标签: r loading
1条回答
Deceive 欺骗
2楼-- · 2019-05-06 15:40

The read.table function ended up working: http://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html

> fossildata <- read.table("fossilien.dat")

EDIT by CGW: load is for files in .rdata format, while your fossilien.dat clearly is an ASCII table. source executes the named file or object.

查看更多
登录 后发表回答