简体   繁体   English

在 R 中读取 an.rdb 文件时出现问题

[英]Problems reading an .rdb file in R

I am trying to read an.rdb file to collect the R codes contained in it.我正在尝试读取 an.rdb 文件以收集其中包含的 R 代码。 However, when using the following code the following error appears, see:但是,使用以下代码时会出现以下错误,请参阅:

> setwd("C:\\Users\\")
> lazyLoad(filebase="treeTaper",envir=parent.frame())
NULL
> 

The message seems to warn that there are no files that can be read, however, there are the files.该消息似乎警告说没有可以读取的文件,但是有文件。 In this case, how can I read this file and then collect the necessary information?在这种情况下,我怎样才能读取这个文件,然后收集必要的信息?

In the link provided below are the files File link: https://drive.google.com/drive/folders/1JzBuH63LiaZNeJDzYvKVWk2utWFJuLdk?usp=sharing在下面提供的链接中是文件文件链接: https://drive.google.com/drive/folders/1JzBuH63LiaZNeJDzYvKVWk2utWFJuLdk?usp=sharing

Note: Currently, the treeTaper package is no longer working, is this the reason?注意:目前,treeTaper package 不再工作,是这个原因吗?

install.packages("treeTaper")
Installing package into ‘C:/Users/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘treeTaper’ is not available (for R version 4.0.2)

The lazyLoad function works primarily by side-effect, which to me means you shouldn't rely on (nor be discouraged by) the NULL output. lazyLoad function 主要通过副作用起作用,对我而言,这意味着您不应该依赖(也不应该气馁) NULL output。

For instance,例如,

ls()
# character(0)
lazyLoad("c:/Users/r2/R/win-library/4.0/yaml/help/yaml", envir = .GlobalEnv)
# NULL
ls()
# [1] "as.yaml"    "read_yaml"  "write_yaml" "yaml.load" 
as.yaml
# \title{ Convert an R object into a YAML string }\name{as.yaml}\alias{as.yaml}\keyword{ data }\keyword{ manip }\description{
#   Convert an R object into a YAML string
# }\usage{
#   as.yaml(x, line.sep = c("\n", "\r\n", "\r"), indent = 2, omap = FALSE,
#           column.major = TRUE, unicode = TRUE, precision = getOption('digits'),
#           indent.mapping.sequence = FALSE, handlers = NULL)
# }.......

If you want the objects to be available in a specific location, then control where it's going a little better.如果您希望对象在特定位置可用,那么控制它的位置会更好一些。 (The envir=parent.frame() you're using seems like it would be polluting the calling environment with these promise objects of help docs.) (您正在使用的envir=parent.frame()似乎会使用帮助文档的这些 promise 对象污染调用环境。)

e <- new.env(parent = emptyenv())
lazyLoad("c:/Users/r2/R/win-library/4.0/yaml/help/yaml", envir = e)
# NULL
ls(e)
# [1] "as.yaml"    "read_yaml"  "write_yaml" "yaml.load" 
e$as.yaml
# \title{ Convert an R object into a YAML string }\name{as.yaml}\alias{as.yaml}\keyword{ data }\keyword{ manip }\description{
#   Convert an R object into a YAML string
# }\usage{
#   as.yaml(x, line.sep = c("\n", "\r\n", "\r"), indent = 2, omap = FALSE,
#           column.major = TRUE, unicode = TRUE, precision = getOption('digits'),
#           indent.mapping.sequence = FALSE, handlers = NULL)
# }......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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