在 R 中读取 .rdb 文件时出现问题
Problems reading an .rdb file in R
我正在尝试读取 .rdb 文件以收集其中包含的 R 代码。但是,使用以下代码时出现以下错误,参见:
> lazyLoad(filebase="treeTaper",envir=parent.frame())
NULL
>
消息似乎警告没有可以读取的文件,但是有文件。在这种情况下,我该如何读取这个文件,然后收集必要的信息?
在下面提供的link中是文件
注意:目前,treeTaper 包已经失效了,是这个原因吗?
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)
lazyLoad
函数主要通过副作用起作用,这对我来说意味着您不应该依赖(也不应气馁)NULL
输出。
例如,
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)
# }.......
如果您希望对象在特定位置可用,那么最好控制它的去向。 (您正在使用的 envir=parent.frame()
似乎会用这些帮助文档的承诺对象污染调用环境。)
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)
# }......
我正在尝试读取 .rdb 文件以收集其中包含的 R 代码。但是,使用以下代码时出现以下错误,参见:
> lazyLoad(filebase="treeTaper",envir=parent.frame())
NULL
>
消息似乎警告没有可以读取的文件,但是有文件。在这种情况下,我该如何读取这个文件,然后收集必要的信息?
在下面提供的link中是文件
注意:目前,treeTaper 包已经失效了,是这个原因吗?
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)
lazyLoad
函数主要通过副作用起作用,这对我来说意味着您不应该依赖(也不应气馁)NULL
输出。
例如,
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)
# }.......
如果您希望对象在特定位置可用,那么最好控制它的去向。 (您正在使用的 envir=parent.frame()
似乎会用这些帮助文档的承诺对象污染调用环境。)
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)
# }......