r - 如何在 RStudio 中查看、打开和保存 .rdb 文件
问题描述
我可以按照此处的方向将变量环境中 .rdb 文件中的每个数据库视为“承诺” 。现在,我想编辑其中一个文件并保存它。我怎样才能做到这一点?我是 R 的新手。
解决方案
在关于r-pkg-devel的讨论中,Ivan Krylov 提供了以下函数来读取 RDB 数据库:
# filename: the .rdb file
# offset, size: the pair of values from the .rdx
# type: 'gzip' if $compressed is TRUE, 'bzip2' for 2, 'xz' for 3
readRDB <- function(filename, offset, size, type = 'gzip') {
f <- file(filename, 'rb')
on.exit(close(f))
seek(f, offset + 4)
unserialize(memDecompress(readBin(f, 'raw', size - 4), type))
}
因此,您应该能够使用 、 和 的组合来实现serialize
反向memCompress
操作writeBin
。
请注意,如果对象更改大小,您还必须调整索引文件。
推荐阅读
- php - 如何在 Woocommerce 上使用简码或 php 代码向访问者显示会员分配的内容?
- visual-studio-code - 如何将参数添加到自定义 vscode 扩展中的自定义命令?
- python - 我的代码一直收到相同的错误“AttributeError:模块'selenium.webdriver'没有属性'get'”
- c++ - 我可以在线程中获得未来的回报吗?
- reactjs - 使用路径(带有“/”)作为 URL 中的参数
- git - Git 别名错误,在 CLI 中运行时始终有效
- macos - 鸭嘴兽抑制状态菜单下拉文本?
- python - 如何在 Python Pandas 中值的开头加载零?没有任何作用
- probability - 给定 X 的值、其均值和方差,如何根据几何分布计算概率?在 R 中
- python - 如何将 pip3 指向我的 python3 文件夹?(苹果电脑)