R Error: bad restore file magic number – no data loaded (2 Examples)

In this R programming tutorial you’ll learn how to deal with the error message “bad restore file magic number (file may be corrupted) — no data loaded”.

Example 1: Replicating the Error Message: bad restore file magic number

saveRDS(iris, "iris.rds")         # Export iris data set
load("iris.rds")                  # Applying load() function (error)
# Error in load("iris.rds") : 
#   bad restore file magic number (file may be corrupted) -- no data loaded
# In addition: Warning message:
# file 'iris.rds' has magic number 'X'
#   Use of save versions prior to 2 is deprecated

Example 2: Solving the Error Message: bad restore file magic number

my_data <- readRDS("iris.rds")    # Properly load iris.rds file

Related Tutorials & Further Resources

Below, you may find some further resources on topics such as numeric values and coding errors.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top