4

I am aware that this question was already posted before, but since it was asked more than eight years ago I was wondering if there is solution now. The suggested answers in that post do not provide a satisfactory solution to the problem: Load attributes of an object without loading the file into memory.

Basically, it would be great to load object's attributes without having to load the file. In case user-written attributes can't be loaded, it would be great to at least be able to load basic attributes such as length or names. The fst::metadata_fst() does something similar, but the problem is that it only saves data.frames, so it does not work with other type of objects like lists.

Thanks.

  • 1
    I don't think that R has had the `load(.)` mechanism changed sufficiently to support partial-read of `.rda` (or `.rds`) files. – r2evans Dec 23 '22 at 15:56
  • perhaps with a package different to base R? – R.Andres Castaneda Dec 27 '22 at 16:41
  • Nothing that I've seen provides this functionality. If it is still possible to load into memory but you just don't want to do that for _this_ instance of R, then you can do this: `res <- callr::r_bg(function() attributes(readRDS("path/to/file.rds"))); res$wait(); res$get_result()`. This does load all of the RDS into another R process, then retrieves the attributes and returns just those attributes to the current R session. – r2evans Dec 27 '22 at 16:46

0 Answers0