R语言summary()报错object of type 'closure' is not subsettable的原因

来源:互联网 发布:矩阵的奇异值有0吗 编辑:程序博客网 时间:2024/06/05 00:13

代码

> library(mice)Error in library(mice) : 不存在叫‘mice’这个名字的程辑包> bad_ind<-accepts[,c("bad_ind")]> x<-accepts[,c("fico_score","tot_derog","tot_rev_line","rev_util","age_oldest_tr")]> imp<-mice(x,met="cart",m=1)#该方法只对数值变量进行插补,分类变量的缺失值保留Error in mice(x, met = "cart", m = 1) : could not find function "mice"> x_imp<-complete(imp)Error in complete(imp) : could not find function "complete"> data<-cbind(bad_ind,x_imp)Error in cbind(bad_ind, x_imp) : object 'x_imp' not found> data1<-data> summary(data1)Error in object[[i]] : object of type 'closure' is not subsettable> r=data1$rev_util#以rev_util里的数据进行盖帽处理Error in data1$rev_util : object of type 'closure' is not subsettable

原因分析

一般出错原因不明时一定要尽量往前倒推,
其实你看,根据这个实例你就会知道,最后summary()一个数据集时给出了
object of type ‘closure’ is not subsettable
错误是不正常的,
往前推就会发现这个错误的源头是第一行:
mice这个包没有提前载入,所以library()是无效的,
最终导致后面的一系列程序都是出错的。
至于summary()为什么会给出那样一个错误信息,这是程序内部设计的问题了。

阅读全文
0 0
原创粉丝点击