R包什么时候导出他们的对象? loadNamespace(partial = TRUE)

时间:2018-03-16 21:08:27

标签: r namespaces shared-libraries

这就是谜题:

> getNamespaceExports(loadNamespace("reprex", partial = TRUE))
character(0)
> getNamespaceExports(loadNamespace("yaml", partial = TRUE))
[1] "as.yaml"        "write_yaml"     "yaml.load"      "yaml.load_file" "read_yaml"     
> getNamespaceExports(loadNamespace("skimr", partial = TRUE))
 [1] "skim_with"            "ends_with"            "list_lengths_min"     "list_min_length"     
 [5] "inline_linegraph"     "min_char"             "num_range"            "n_empty"             
 [9] "show_formats"         "ts_end"               "starts_with"          "list_lengths_max"    
[13] "skim"                 "list_max_length"      "inline_hist"          "skim_format_defaults"
[17] "sorted_count"         "skim_to_list"         "n_missing"            "one_of"              
[21] "matches"              "contains"             "ts_start"             "n_unique"            
[25] "get_skimmers"         "pander"               "list_lengths_median"  "skim_with_defaults"  
[29] "everything"           "show_skimmers"        "skim_format"          "max_char"            
[33] "skim_to_wide"         "%>%"                  "n_complete"           "skim_tee"            
[37] "kable"               
> getNamespaceExports(loadNamespace("microbenchmark", partial = TRUE))
character(0)

有些包在调用loadNamespace(partial = TRUE)时导出内容;别人不这样做。任何人都可以解释造成这种变化的原因吗?

1 个答案:

答案 0 :(得分:2)

回答我自己的问题。不同之处在于我在.Rprofile中间接加载了其中一些软件包。使用R --vanilla运行相同的命令总是为所有包提供空导出 - 除了像“utils”这样的核心包,我猜这些包总是被加载。