Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

database - 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:

> 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

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)
question from:https://stackoverflow.com/questions/65873300/problems-reading-an-rdb-file-in-r

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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
# itle{ Convert an R object into a YAML string }
ame{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("
", "
", "
"), 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
# itle{ Convert an R object into a YAML string }
ame{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("
", "
", "
"), indent = 2, omap = FALSE,
#           column.major = TRUE, unicode = TRUE, precision = getOption('digits'),
#           indent.mapping.sequence = FALSE, handlers = NULL)
# }......

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...