本文介绍了加载包 SASxport 时出错:对象 'label<-.data.frame' 未由 'namespace:Hmisc' 导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 XPT 格式的数据读入 R(该格式可以在例如 NHANES 数据).我发现有两个函数可以这样做:

I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing this:

library("Hmisc")
sasxport.get("C:/path/file.XPT")

library("SASxport")
read.xport("C:/path/file.XPT")

sasxport.get 工作正常,所以我基本上没问题,但仍然好奇地理解(并解决)以下错误:安装 SASxport 后包,我无法加载它.当我运行 library("SASxport") 时,我收到错误消息:

The sasxport.get works, so I'm basically fine, but still inquisitive enough to understand (and solve) the following error: after the installation of the SASxport package, I cannot load it. When I run library("SASxport"), I get the error message:

Error: package or namespace load failed for ‘SASxport’:
 object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'

采纳这个建议,我也跑了

remove.packages(c("SASxport", "Hmisc"))
install.packages('Hmisc', dependencies = TRUE)
install.packages('SASxport', dependencies = TRUE)

什么没有改变错误信息.

what did not change the error message.

这是我的 sessionInfo():

R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] Hmisc_4.1-1     ggplot2_2.2.1   Formula_1.2-2   survival_2.41-3 lattice_0.20-35

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.14        pillar_1.0.1        compiler_3.4.3      RColorBrewer_1.1-2  plyr_1.8.4
 [6] base64enc_0.1-3     iterators_1.0.9     tools_3.4.3         rpart_4.1-11        digest_0.6.13
[11] tibble_1.4.1        gtable_0.2.0        htmlTable_1.11.1    checkmate_1.8.5     rlang_0.1.6
[16] icenReg_2.0.7       Matrix_1.2-12       foreach_1.4.4       rstudioapi_0.7      yaml_2.1.16
[21] gridExtra_2.3       coda_0.19-1         stringr_1.2.0       cluster_2.0.6       knitr_1.18
[26] htmlwidgets_0.9     grid_3.4.3          nnet_7.3-12         data.table_1.10.4-3 foreign_0.8-69
[31] latticeExtra_0.6-28 magrittr_1.5        scales_0.5.0        backports_1.1.2     codetools_0.2-15
[36] htmltools_0.3.6     splines_3.4.3       colorspace_1.3-2    stringi_1.1.6       acepack_1.4.1
[41] lazyeval_0.2.1      munsell_0.4.3

推荐答案

SASxport的最后一次更新发生在近两年前(2016-03-11).因此,它导入的 Hmisc 包可能同时发生了变化.查找 Hmisc 存档 我找到了 2016 年的版本号-03-11 为 3.17-2.所以安装这个版本解决了这个问题:

The last update of SASxport happend nearly two years ago (2016-03-11). So the Hmisc package it imports might have changed in the meantime. Looking up the Hmisc archive I found the version number on 2016-03-11 to be 3.17-2. So installing this version fixes the problem:

library("devtools")
install_version("Hmisc", version = "3.17-2")

在这种情况下反对使用 SASxport 的原因有两个:

Two reasons speak against using SASxport in this case:

  1. 您需要使用旧版本的软件包,这可能会影响您在后续步骤中的工作.
  2. SASxport 需要 Hmisc 来完成 Hmisc 已经可以自己完成的任务,因此 SASxport 在以下情况下是可消耗的读取 XPT 文件.
  1. You need to use a old version of a package which might happer your work in later steps.
  2. SASxport needs Hmisc for a task that Hmisc can do already by itself, so SASxport is expendable when reading in XPT files.

这篇关于加载包 SASxport 时出错:对象 'label&lt;-.data.frame' 未由 'namespace:Hmisc' 导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-05 06:31