I have a dataframe and a list of eigenvectors. I am trying to take the list of eigenvectors, match each one (they are in order) to the dataframe column and return a dataframe that contains only columns where the eigenvector is greater than 1. My pseudo code for it would look something like this:
1) get eigenvalues for matrix stored as variable (called: ev)
2) iterate through each element of ev
3) check if the absolute value of the element is greater then 1
    3a) if so, return dataframe column
I am trying to do that is R like this:
#1
count=0
matr<as.matrix(MY_DF)
matr_temp1<-matr[,1:length(matr[,1])]#force matrix to drop COLS to have same number rows as cols
ev<-eigen(matr_temp1)$values
#2
result<-lapply(ev, function(x){
  count+=1
  if((abs(x)>1),return count)
})
#3
abs(x)>1
#3a
#convert numbers to df columns
df=subset(df,select=c(result))
Obviously this needs work, Can someone suggest changes? An explanation would be awesome :)
a snippet from the dataframe that is converted to a matrix (let me know if you need more data)
    > df[1:5,1:5]
  achievement.mineWood achievement.openInventory dyad_number stat.damageDealt stat.damageTaken
1                    2                         6           1             1170             2210
2                   17                        12           1              840              800
3                   48                        37           2             2595              520
4                   16                        22           3             5410             3105
5                   36                         6           3             2720             3300
first 5 eigenvalues:
> ev[1:5]
[1]  646127.12+    0.00i -118038.12+    0.00i   65537.13+    0.00i  -34741.55+33905.02i  -34741.55-33905.02i
