I have a series of data frames, df1 df2, where each data frame follow this structure:
x <- c(1:5)
y <- c(1:5)
df1 <- data
Just use length(dfList)?
for(i in 1:length(dfList))
{
a <- grep("One", names(dfList[[i]]))
... #etc.
}
Using lapply will be faster.
ChangeNames = function(Data)
{
a = grep("One", names(Data))
b = grep("Two", names(Data))
names(Data)[c(a,b)] <- c("R1", "R2")
return(Data)
}
lapply(dfList, ChangeNames) #Returns list of renamed data frames.