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
> df1 <- data.frame("Row One"=x, "Row Two"=y)
> df2 <- data.frame("Row Two"=y,"Row One"=x)
> dfList <- list(df1,df2)
> lapply(dfList, function(x) {
names(x)[ grep("One", names(x))] <- "R1"
names(x)[ grep("Two", names(x))] <- "R2"
x} )
[[1]]
R1 R2
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
[[2]]
R2 R1
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5