R:bestglm中的错误-if(any(Column1Test))stop中的错误(“1和x27的列不能使用!始终包括截取”)

R:bestglm中的错误-if(any(Column1Test))stop中的错误(“1和x27的列不能使用!始终包括截取”),r,glm,R,Glm,我试图运行bestglm命令,但收到错误消息 if(any(Column1Test))stop中出错(“无法使用1的列!始终包含截获”):缺少需要TRUE/FALSE的值 以下是bestglm函数错误消息的源代码: #Test if there is a column of 1's in X. #Only do this test if: #1) X contains at least one column corresponding to a quantitative variable #

我试图运行bestglm命令,但收到错误消息

if(any(Column1Test))stop中出错(“无法使用1的列!始终包含截获”):缺少需要TRUE/FALSE的值

以下是
bestglm
函数错误消息的源代码:

#Test if there is a column of 1's in X. 
#Only do this test if:
#1) X contains at least one column corresponding to a quantitative variable 
#2) IncludeInterceptQ (intercept is included already)
if (!all(FactorsQ)&& IncludeInterceptQ){
    X2<-X[,!FactorsQ,drop=FALSE] #removing factor variables
    p2<-ncol(X2)
    Column1Test<-apply(X2-matrix(rep(1,n*p2),ncol=p2), MARGIN=2, function(x) 0==sum(abs(x)))
    if (any(Column1Test))
      stop("Column of 1's can't be used! Intercept always included.")
}
#测试X中是否有一列1。
#仅在以下情况下进行此测试:
#1) X至少包含一个与定量变量对应的列
#2) IncludeInterceptQ(已包含截取)
如果(!所有(因子Q)和&IncludeInterceptQ){

X2我遇到了相同的错误,通过删除bestglm命令中包含的变量中的NAs解决了这个问题。您可以从原始数据帧DF中删除NAs,如下所示:

df <- DF[is.na(DF$foo)==F & is.na(DF$bar)==F,]
df
df <- DF[is.na(DF$foo)==F & is.na(DF$bar)==F,]