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