I'm dealing with a quite complicated data frame. I'm trying to rename its columns by adding some terminal digits to each column several times. How can I do that?
Let me make an example:
df=data.frame(disease=c("HB1","HB2","HB3","HB4"),
region="AZ",
hospitalAZ=runif(4),
hospitalAZ=runif(4),
hospitalAZ=runif(4),
hospitalAZ=runif(4))
This is just a stupid example. The outcome should be: the columns after "region" should be named HospitalAZ1, HospitalAZ2, HospitalAZ1, HospitalAZ2. I looking for a parsimonious way of adding, in this case, 1 and 2 to the 4 columns with repetition (2 times in this case). Then, how can I extract the outcome in an xls file?