如何使用R打开.rdb文件(How to open .rdb file using R)

编程入门 行业动态 更新时间:2024-10-28 15:31:56
如何使用R打开.rdb文件(How to open .rdb file using R)

我的问题很简单,但我无法在任何地方找到答案。 如何使用R打开.rdb文件?

它放在R包内。

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.

最满意答案

我已经能够解决这个问题了,所以我在这里发布答案以防将来有人需要它。

#### 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.

使用lazyLoad函数的结果是.rdb文件中包含的每个数据库都在变量环境中显示为“promise”。 这意味着除非您想要数据库,否则不会打开数据库。

打开它的方法如下:

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

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.

更多推荐

本文发布于:2023-07-29 18:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1318698.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   文件   file   rdb   open

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!