find the serialization version of an R .rds file

Viewed 305

R 3.6 have started saving by default RDS files with version = 3. having a list of mixed formats .rds files (ones from R 3.4 and ones from 3.6) how do I know which ones have version 2 and which have version 3?

thanks

1 Answers

There is now a function infoRDS which returns information about the serialization, including the version. I believe this function was added in R 4.0.0 (April, 2020).

If you are using an older version of R you can use use the internal function:

tools:::get_serialization_version("path/to/saved-file.RDS")

Note that when creating packages, using internal functions is discouraged. From the Writing R Extensions manual:

Using foo:::f instead of foo::f allows access to unexported objects. This is generally not recommended, as the semantics of unexported objects may be changed by the package author in routine maintenance.

Where I learned about get_serialization_version: https://r.789695.n4.nabble.com/What-is-the-best-way-to-determine-the-version-of-an-rds-td4758243.html

Related