Hi,
Try:
dat<- data.frame(id=1:3,abcmor=2:4,relmor=c(5,4,3), neomor=c(6,3,1), 
Column5=c(4,8,1) ) 


colnames(dat)[grep("mor",colnames(dat))] <- 
gsub("mor$","",colnames(dat)[grep("mor",colnames(dat))])
dat
A.K.


I have several columns which all end with "mor". How can I remove the suffix 
mor for all columns? id abcmor relmor neomor
1   2         5        6
2   3         4       3
3   4         3       1

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to