Q: Add column to every data frame of a list and apply a function I have a  list[14] (sujets) of data frames. I would like to add a column to every data frame of the list. Every data frame has the same number of columns, but a different number of rows.
> summary(sujets)
         Length Class      Mode
Sujet 1  85     data.frame list
Sujet2   85     data.frame list  
Sujet 3  85     data.frame list
SUjet 4  85     data.frame list
Sujet 5  85     data.frame list
Sujet 6  85     data.frame list 
Sujet 7  85     data.frame list
Sujet 8  85     data.frame list
Sujet 9  85     data.frame list
Sujet 10 85     data.frame list
Sujet 11 85     data.frame list
Sujet 12 85     data.frame list
SUjet 13 85     data.frame list
Sujet 14 85     data.frame list

In this column, I would like to apply the following : function(x) 0.001*x.
With x the row number of sujets[[i]][[86]], the column added to every data frame.
I tried many different options but none worked...
When I try to add a new column to every data frame, it is of type factor which stops me from applying a function.
Thank you very much for your help !
Update
Thank your for your answers, the following code eventually worked for me :
        for (i in 1:nbrSujet) {
          nrows = nrow(sujets[[i]])
          ncols = ncol(sujets[[i]])
       Timestamp <- c(1:nrows)
         for (j in 1:nrows) {
    Timestamp[j] = 0.001*j
  }
  
  sujets[[i]]$Timestamp <- Timestamp
}

I get a new column in each data frame of my list, to which I apply, on every row[j] the function(x) 0.001*x.
Sorry if my explanations were not very clear, I am new to R, I will be more specific next time :)

A: If you can please supply a toy example for us to work with.
This possible solution comes to mind:
require(dplyr)
l <- lapply(sujets, function(x) {
x <- x %>% mutate(newvariable = 0.001*nrow(x))
})


With x the row number of sujets[[i]][[86]], the column added to every data frame.

This phrase is not 100% clear to me, I hope that I got it right in my answer.
