简体   繁体   English

如何在RStudio中编辑.rds文件?

[英]How do you edit a .rds file in RStudio?

I am trying to run an R script that I've inherited from a colleague. 我正在尝试运行从同事那里继承来的R脚本。 This script references a .rds file called config.rds. 该脚本引用了一个名为config.rds的.rds文件。 It stores some configuration settings. 它存储一些配置设置。 I need to change those settings. 我需要更改这些设置。 However, when I attempt to open the file in the Rstudio editor, a "Load R object" prompt pops up. 但是,当我尝试在Rstudio编辑器中打开文件时,弹出“加载R对象”提示。 I cannot figure out how to open the file for editing. 我不知道如何打开文件进行编辑。

You can't open the file for editing - it is a binary file that stores the internal representation of R data objects. 您无法打开文件进行编辑-这是一个二进制文件,其中存储R数据对象的内部表示形式。

You can only really read it into R to create a new R object, and then save a modified copy of that R object into a new or (the same) .RDS file. 您只能将其真正读入R以创建新的R对象,然后将该R对象的修改后的副本保存到新的(或相同的).RDS文件中。 Example: 例:

config = readRDS("config.rds")
config$username = "fnord"
saveRDS(config, "config.rds")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM