我有以下要尝试执行的代码块。我正在for循环中为表中所有可能的预测变量调用lm_model
函数。但是,当我尝试从模型摘要中提取系数时,出现以下错误:Error: Index 1 must be a character or numeric vector
能否让我知道我要去哪里错了?
lm_model<- function(df1,i){
model_summary <- list()
fit_model[[i]] <- lm(paste("distance ~", i), data = df1)
model_summary[[i]] <- summary( fit_model[[i]])
return(model_summary)
}
for( i in names(FAA_final[,1:7])){
summary_normal[i] <- lm_model(FAA_final, paste(i))
}
for(i in length(fit_normal)){
coefficients[i] <- map(fit_normal[[i]],coefficients)
}