R 找不到函数';的继承方法;完成';签名'&引用;mids"&引用;“数字”';

R 找不到函数';的继承方法;完成';签名'&引用;mids"&引用;“数字”';,r,R,我刚刚用conda安装了Rstudio和R,并尝试遵循本教程: 我一直跑到这一步 > completeData <- complete(imputed_Data,2) 我试过回溯 有关完整信息: 我运行的代码是: library("mice") library("Amelia") library("Hmisc") library("mi") library("missForest") data <- iris iris.mis <- prodNA(iris, no

我刚刚用conda安装了Rstudio和R,并尝试遵循本教程:

我一直跑到这一步

> completeData <- complete(imputed_Data,2)
我试过回溯

有关完整信息:

我运行的代码是:

library("mice")
library("Amelia")
library("Hmisc")
library("mi")
library("missForest")


data <- iris
iris.mis <- prodNA(iris, noNA = 0.1)
imputed_Data <- mice(iris.mis, m=5, maxit = 50, method = 'pmm', seed = 500)
completeData <- complete(imputed_Data,2)
库(“鼠标”)
图书馆(“阿米莉亚”)
图书馆(“Hmisc”)
图书馆(“mi”)
图书馆(“密斯森林”)
数据库(“mi”)
加载所需包:矩阵
加载所需包:stats4
mi(版本1.0,打包:2015-04-16 14:03:10 UTC;古德里奇)
密歇根大学版权所有(C)2008、2009、2010、2011、2012、2013、2014、2015哥伦比亚大学受托人
这个程序绝对没有保修。
这是免费软件,欢迎您重新发布
在通用公共许可证版本2或更高版本下。
执行RShowDoc(“复制”)以了解详细信息。
附加包:“mi”
以下对象被“包:鼠标”屏蔽:
完成,池
>图书馆(“密斯森林”)
正在加载所需的包:randomForest
随机森林4.6-12
键入rfNews()以查看新功能/更改/错误修复。
正在附加包:“随机森林”
以下对象已从“包:ggplot2”中屏蔽:
边缘
加载所需包:foreach
加载所需包:itertools
加载所需包:迭代器
> 
> 
>数据iris.mis插补_数据完成数据

当查看包含名称引发该错误的函数的文档时,需要查看“上游”中已加载的包。在该页面内使用浏览器的搜索功能搜索
库时,我看到:

 #install package and load library
> install.packages("Amelia")
> library(Amelia)
还有其他几个包裹。您需要查看在复制代码之前加载的任何包

==编辑====

对于
完整的
功能,本质上存在相互竞争的方法。由于上次加载了
mi
包,因此调用了它的
complete
函数,但它与
mices::complete
函数有些不同,并且它无法识别由
mices
-函数创建的mids类对象。如果强制调用适当的函数,则不会出现错误:

completeData <- mice::complete(imputed_Data,2)
str(completeData)
'data.frame':   150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 5 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "contrasts")= num [1:3, 1:2] 0 1 0 0 0 1
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr  "setosa" "versicolor" "virginica"
  .. .. ..$ : chr  "2" "3"

completeData我已加载库而没有问题,否则,我无法获取插补的_数据。但这就是我得到相同错误的原因。
R.Version()$Version.string
packageVersion(“鼠标”)
?>R.Version()$Version.string[1]“R Version 3.4.3(2017-11-30)”>packageVersion(“鼠标”)[1]“2.46.0”的输出是什么?您可能希望将R更新到3.4.4。显然,您已经安装并加载了
鼠标
,并且可以创建
“mids”
对象,但它在查找方法时遇到了问题。本教程在R3.4.4上运行时没有问题,带有
鼠标
版本2.46.0。我只是在控制台上键入了函数名,得到了以下信息:
complete\standardGeneric,用于从包“mi”
中定义的“complete”。此外,当我键入
?complete
时,我机器上的帮助系统提出了三种可能性,这一事实增加了具有竞争性功能定义的可能性。(第三个是在tidyr包中。)我对这种重叠和矛盾行为有类似经历的另一个函数名是函数名:
descriple
。我以前已经加载了所有必需的库….>库(“鼠标”)>library(“Amelia”)>library(“missForest”)>library(“鼠标”)>library(“Hmisc”)>>CompletedData
complete
不在
Amelia
中。它在
鼠标中
。所以,@user40780。。。。我的建议你都看过了吗?@42-,谢谢你的信息。我正在努力理解这一切。但由于我刚刚开始使用R,我有点困难……如果你不匆忙下结论,而是深呼吸,慢慢仔细地阅读答案和评论,你会有一个更轻松的时间。
library("mice")
library("Amelia")
library("Hmisc")
library("mi")
library("missForest")


data <- iris
iris.mis <- prodNA(iris, noNA = 0.1)
imputed_Data <- mice(iris.mis, m=5, maxit = 50, method = 'pmm', seed = 500)
completeData <- complete(imputed_Data,2)
> library("mice")
Loading required package: lattice
> library("Amelia")
Loading required package: Rcpp
## 
## Amelia II: Multiple Imputation
## (Version 1.7.4, built: 2015-12-05)
## Copyright (C) 2005-2018 James Honaker, Gary King and Matthew Blackwell
## Refer to http://gking.harvard.edu/amelia/ for more information
## 
> library("Hmisc")
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, units

> library("mi")
Loading required package: Matrix
Loading required package: stats4
mi (Version 1.0, packaged: 2015-04-16 14:03:10 UTC; goodrich)
mi  Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Trustees of Columbia University
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under the General Public License version 2 or later.
Execute RShowDoc('COPYING') for details.

Attaching package: 'mi'

The following objects are masked from 'package:mice':

    complete, pool

> library("missForest")
Loading required package: randomForest
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.

Attaching package: 'randomForest'

The following object is masked from 'package:ggplot2':

    margin

Loading required package: foreach
Loading required package: itertools
Loading required package: iterators
> 
> 
> data <- iris
> iris.mis <- prodNA(iris, noNA = 0.1)
> imputed_Data <- mice(iris.mis, m=5, maxit = 50, method = 'pmm', seed = 500)

 iter imp variable
  1   1  Sepal.Length  Sepal.Width  Petal.Length  Petal.Width  Species
 ...
  50   4  Sepal.Length  Sepal.Width  Petal.Length  Petal.Width  Species
  50   5  Sepal.Length  Sepal.Width  Petal.Length  Petal.Width  Species
> completeData <- complete(imputed_Data,2)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function 'complete' for signature '"mids", "numeric"'
> 
 #install package and load library
> install.packages("Amelia")
> library(Amelia)
completeData <- mice::complete(imputed_Data,2)
str(completeData)
'data.frame':   150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 5 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "contrasts")= num [1:3, 1:2] 0 1 0 0 0 1
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr  "setosa" "versicolor" "virginica"
  .. .. ..$ : chr  "2" "3"