0

I have a list of 12000 elements. I want to add a column to each element in which the column name/number is displayed with a minimum of 6 row values. I can do this for a single element, but unfortunately not in a way that it works for all list elements.

Here is my code so far:

l2<-lapply(adresults_df_list, function(x) 
  cbind(x, bf = NA))

for(i in 1:12000){
adresults_df_list[[i]]$bf <- apply(adresults_df_list[[i]][,1:6], 1, function(x) which(x==min(x)))    
}

Mayby I can do this with lapply or a loop?

AnnE
  • 13
  • 3
  • 2
    Without a [minimum reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) it is difficult to answer what you are trying to ask. – Abhijeet Sep 22 '20 at 14:12
  • 1
    Can you create a small example with 2-3 dataframes in a list where each dataframe has 4-5 rows and show expected output based on that? – Ronak Shah Sep 22 '20 at 14:29

0 Answers0