I am working with a list, I want to loop a variable several times but I can't.
This is the example:
a=data.frame(ID=1:5,WT=1:5)
b=data.frame(ID=101:105,WT=101:105)
c=list(a,b)
names(c)=c("P01","P02")
Now I want to add a new column to each data frame
c$P01$seq=1:length(c$P01$ID)
c$P02$seq=1:length(c$P02$ID)
The problem that I got is that my list has 29 data frames, not two like in this example. How can I automatise this process, so I can add a new column to each data frame?
I've tried few things with no success like creating a loop, but it doesn't not work:
unique=names(c)
for (i in 1:length(unique) {
c$unique[i]$seq=1:length(c$unique[i]$seq)
}