user55546
user55546

Reputation: 62

Problems reading an .rdb file in R

I am trying to read an .rdb file to collect the R codes contained in it. However, when using the following code the following error appears, see:

> 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

Note: Currently, the treeTaper package is no longer working, is this the reason?

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)

Upvotes: 0

Views: 942

Answers (1)

r2evans
r2evans

Reputation: 160407

The lazyLoad function works primarily by side-effect, which to me means you shouldn't rely on (nor be discouraged by) the 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.)

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

Upvotes: 1

Related Questions