bad restore file magic number error in R
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.
workspace cannot be loaded in server, file has magic number 'RDX3'
Did you update R in your computer recently? If you did, from R 3.5.0, RData are saved using version 3 by default (RDX3). If you have an earlier version of R in your server, you probably need to save your data using the right version for your server (updating R in your server is another option). Please check the option version
in the help of the save
command to learn how to do that.
What's the bad magic number error?
The magic number comes from UNIX-type systems where the first few bytes of a file held a marker indicating the file type.
Python puts a similar marker into its pyc
files when it creates them.
Then the python interpreter makes sure this number is correct when loading it.
Anything that damages this magic number will cause your problem. This includes editing the pyc
file or trying to run a pyc
from a different version of python (usually later) than your interpreter.
If they are your pyc
files, just delete them and let the interpreter re-compile the py
files. On UNIX type systems, that could be something as simple as:
rm *.pyc
or:
find . -name '*.pyc' -delete
If they are not yours, you'll have to either get the py
files for re-compilation, or an interpreter that can run the pyc
files with that particular magic value.
One thing that might be causing the intermittent nature. The pyc
that's causing the problem may only be imported under certain conditions. It's highly unlikely it would import sometimes. You should check the actual full stack trace when the import fails?
As an aside, the first word of all my 2.5.1(r251:54863)
pyc
files is 62131
, 2.6.1(r261:67517)
is 62161
. The list of all magic numbers can be found in Python/import.c
, reproduced here for completeness (current as at the time the answer was posted, it may have changed since then):
1.5: 20121
1.5.1: 20121
1.5.2: 20121
1.6: 50428
2.0: 50823
2.0.1: 50823
2.1: 60202
2.1.1: 60202
2.1.2: 60202
2.2: 60717
2.3a0: 62011
2.3a0: 62021
2.3a0: 62011
2.4a0: 62041
2.4a3: 62051
2.4b1: 62061
2.5a0: 62071
2.5a0: 62081
2.5a0: 62091
2.5a0: 62092
2.5b3: 62101
2.5b3: 62111
2.5c1: 62121
2.5c2: 62131
2.6a0: 62151
2.6a1: 62161
2.7a0: 62171
How to avoid magic numbers?
Try to model the problem domain.
Start with a class Cards
where a card is constructed providing rank (Ace, 2, 3, .., Jack, Queen, ..), a suit (clubs, diamonds, hearts) and a int value which depends on the game you play. In any game a card represents some value, maybe nothing (0) but never -1.
Next, complete your domain by creating a class Hand
, which is a collection of Card
s, and some methods to calculate the total value of the hand based on the cards it is composed of.
Maybe add a class Deck
that you can use to init all 52 Cards and deal from.
Etc.
Related Topics
How to Place Grobs with Annotation_Custom() at Precise Areas of the Plot Region
How to Get the Classes of All Columns in a Data Frame
How to Plot with a Png as Background
Difference Between Passing Options in Aes() and Outside of It in Ggplot2
Line Break When No Data in Ggplot2
Generate Random Numbers with Fixed Mean and Sd
Ggplot2: Change Order of Display of a Factor Variable on an Axis
How to Loop/Repeat a Linear Regression in R
A Matrix Version of Cor.Test()
Remove Columns from Dataframe Where Some of Values Are Na
Angle Between Two Vectors in R
Why Is Allow.Cartesian Required at Times When When Joining Data.Tables with Duplicate Keys
Sum All Values in Every Column of a Data.Frame in R
Adding Text to a Grid.Table Plot
Ggplot2: Curly Braces on an Axis
Convert Seconds to Days: Hours:Minutes:Seconds