How to open .rdb file using R

纵饮孤独 提交于 2019-12-04 01:33:09

问题


My question is quite simple, but I couldn't find the answer anywhere. How do I open a .rdb file using R?

It is placed inside an R package.


回答1:


I have been able to solve the problem, so I am posting the answer here in case someone needs it in the future.

#### Importing data from .rdb file ####

setwd("path...\\Rsafd\\Rsafd\\data")  # Set working directory up to the file that contains
# your .rds and .rdb files.

readRDS("Rdata.rds")  # see metadata contained in .rds file

# lazyLoad is the function we use to open a .rdb file:
lazyLoad(filebase = "path...\\Rsafd\\Rsafd\\data\\Rdata", envir = parent.frame())
# for filebase, Rdata is the name of the .rdb file.
# envir is the environment on which the objects are loaded.

The result of using the lazyLoad function is that every database contained in the .rdb file shows up in your variable environment as a "promise". This means that the database will not be opened unless you want it to be.

The way to open it is the following:

find(HOWAREYOU)  # open the file named HOWAREYOU
head(HOWAREYOU)  # look at the first entries, just to make sure

Edit: readRDS is not part of the process to open the .rdb file, it is just to look at the metadata. The lazyLoad function indeed opens .rdb files.



来源:https://stackoverflow.com/questions/46184224/how-to-open-rdb-file-using-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!