I'm trying to remove specific numbers and characters from the column names in a data frame in R but am only able to remove the numbers, have tried different manners but still keep the characters at the end.
Each column is represented as letters and then a number in parenthesis; e.g. ASE (232)
DataFrame
Subject ASE (232) ASD (121) AFD (313)
1 1.1. 1.2 1.3
Desired Data Frame
Subject ASE ASD AFD
1 1.1 1.2 1.3
Code
colnames(data)<-gsub("[A-Z] ([0-9]+)","",colnames(data))