I have a 3d array in R which takes quite some time to calculate.
I am looking for the easiest way to store this array so it can be read back into R quickly and in an array format.
Can anyone explain how to do this?
I have tried using
saveRDS(x_out, file="x_out.Rda")
x_out1 <- load(file="x_out.Rda")
but this leads to an error.
Error: bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file ‘x_out.Rda’ has magic number 'X'
Use of save versions prior to 2 is deprecated
Any suggestions?
Bad magic file type errors are usually because you're trying to use the wrong function to read a particular file type.
The inverse of saveRDS is readRDS, not load.
Demo:
saveRDS(c(1:3), "test.rds")
x <- load("test.rds")
# 'Error: bad restore file magic number (file may be corrupted) -- no data loaded
# In addition: Warning message:
# file ‘test.rds’ has magic number 'X'
# Use of save versions prior to 2 is deprecated
x <- readRDS("test.rds")
x
# [1] 1 2 3
I am saving and loading 3D numeric arrays just with save() and load() commands:
save(x, file="something.rda")
load("something.rda")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With