gpt4 book ai didi

arrays - 在 R 中保存 3d 数组的最佳方法

转载 作者:行者123 更新时间:2023-12-03 16:00:43 25 4
gpt4 key购买 nike

我在 R 中有一个 3d 数组,需要相当长的时间来计算。

我正在寻找存储此数组的最简单方法,以便可以以数组格式快速将其读回 R。

谁能解释一下如何做到这一点?

我尝试过使用

saveRDS(x_out, file="x_out.Rda")
x_out1 <- load(file="x_out.Rda")

但这会导致错误。

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

有什么建议吗?

最佳答案

Bad magic 文件类型错误通常是因为您尝试使用错误的函数来读取特定文件类型。

saveRDS的倒数是readRDS,而不是load

演示:

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

关于arrays - 在 R 中保存 3d 数组的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26165980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com