简体   繁体   中英

How do you edit a .rds file in RStudio?

I am trying to run an R script that I've inherited from a colleague. This script references a .rds file called config.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. 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.

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. Example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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