Skip to content
Prev 327549 / 398502 Next

linear fit function with NA values

Hi

Quick question. I am running a multiple regression function for each column of two data sets. That means as a result I get several coefficients. I have a problem because data that I use for regression contains NA. How can I ignore NA in lm function. I use the following code for regression: 
OLS<-lapply(seq_len(ncol(es.w)),function(i) {lm(es.w[,i]~es.median[,i])})
as response I get
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  all values NA

thanks for help :)