names(mydat)[c(name)]<-c("newname")
From this, I know that the column/variable name "name" of the data frame mydat is replaced with "newname".
My question is if, I want to do this by a loop so that I will have some thing like:
newname1 newname2 newname3 newname4 and so on, how do I do it?
This is what did and it did not work:
for(i in 1:4){
names(mydat)[c(name)]<-c("newname"i)
}
Is there a way to code this? many thanks to all who could be of help. Owusu Isaac