I have a dataframe mydf with n number of columns with same column name say name. I want to change them to name1 name2 and name3 ..name-nth
mydf
name
name1 name2 and name3 ..name-nth
cols <- names(dat) == "name" names(dat)[cols] <- paste0("name", seq.int(sum(cols)))