I try to remove in R, some characters unwanted from my column names (numbers, . and space) I have column names as follows
My data is tibble
tibble [33 x 38] (S3: tbl_df/tbl/data.frame)
$ year : chr [1:33] "1988" "1989" "1990" "1991" ...
$ VALOR AGREGADO BRUTO (a precios básicos) : num [1:33] 9906283 11624212 14163419 17400488 19785184 ...
$ 1. PRODUCTOS AGRÍCOLAS NO INDUSTRIALES : num [1:33] 831291 911372 1112167 1434213 1532067 ...
$ 2. PRODUCTOS AGRÍCOLAS INDUSTRIALES : num [1:33] 143426 214369 231168 341144 282777 ...
$ 3. COCA : num [1:33] 118273 153689 195108 190264 199259 ...
And I desired column names were.
tibble [33 x 38] (S3: tbl_df/tbl/data.frame)
$ year : chr [1:33] "1988" "1989" "1990" "1991" ...
$ VALOR AGREGADO BRUTO (a precios básicos) : num [1:33] 9906283 11624212 14163419 17400488 19785184 ...
$ PRODUCTOS AGRÍCOLAS NO INDUSTRIALES : num [1:33] 831291 911372 1112167 1434213 1532067 ...
$ PRODUCTOS AGRÍCOLAS INDUSTRIALES : num [1:33] 143426 214369 231168 341144 282777 ...
$ COCA : num [1:33] 118273 153689 195108 190264 199259 ...
I want remove number and . from colnames
colnames(data) <- sub("\\1:4\.\\", "", colnames(data))
colnames(data)
Please somebody could help me?
Best! Marcelo