I have 677 dependent and 1 independent variable as follows. I want to run a regression of each 677 column on the independent variable. Its been asked previously but it doesn't work in my case. In addition, I would like to collect the coefficients in one vector and later to regress back to other variables.
'data.frame':   240 obs. of  678 variables:
 $ X1998.01.12  : num  -0.0006958 -0.0019206 -0.0025667 -0.0031404 -0.0000429 ...
 $ X1998.02.12  : num  0.0032112 -0.0002508 0.0010668 -0.0000417 0.0036056 ..
I run the following code:
pred = df[,c(1:677)]; 
pred=as.matrix(pred)
y=df[,c(678)]
my_lms <- lapply(de, function(x) lm(pred~y))
However, I am having an error:
Error in model.frame.default(formula = pred ~ y, drop.unused.levels = TRUE) :
invalid type (list) for variable 'pred'
Any help is appreciated!
NB: Added below after comments.
list_out <- lapply(colnames(de)[1:677], function(i)
tidy(lm(as.formula(paste(x ~ de$X678,i)), data = de)))
Error message is
Error in parse(text = x, keep.source = FALSE) : 
  <text>:2:3: unexpected symbol
1: ~ X1
2: x X1
     ^ 
 
     
    