'why the error that row names contain missing values occur

My code is like below and I got an error in data.frame(c(b)) : row names contain missing values.

col_name<-colnames(portfolio_25)[2:26]
#b<-seq(from = 1, to=25, by=1) no error if I use this line of code instead of the below one
b<-seq(from =0.5, to=3, by =0.1)

names(b)<-col_name

for(i in col_name){
  lm2 = lm(paste0("I(`",i,"`- RF) ~ I(`Mkt-RF` - RF)"), data = Join_table)
  b[i] =  lm2$coefficients[2]
}

plot <- data.frame(c(b))

The commented and uncommented codes are basically following the same logic, so I didn't get why this error occur.

Any help pls would be great!

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source