I have a dataset dtAU where the columns names are the following:
...
"SUPG..SU.Product.Group"
"SUPC..SU.Industry.Code"
"SU_CAT..SU.Category"
"FREQUENCY..Frequency"
"TIME_PERIOD..Time.Period"
...
I want to get the colnames as "SUPG", "SUPC", etc... so to extract only the character before the ".." and assign them as column names.
When I try this
test <- str_split(colnames(dtAU), "[..]")
I got :
List of 11
$ : chr [1:3] "ï" "" "DATAFLOW"
$ : chr [1:5] "SUPG" "" "SU" "Product" ...
$ : chr [1:5] "SUPC" "" "SU" "Industry" ...
$ : chr [1:4] "SU_CAT" "" "SU" "Category"
$ : chr [1:3] "FREQUENCY" "" "Frequency"
$ : chr [1:4] "TIME_PERIOD" "" "Time" "Period"
$ : chr "OBS_VALUE"
$ : chr [1:4] "UNIT_MEASURE" "" "Observation" "Comment"
$ : chr [1:5] "UNIT_MULT" "" "Unit" "of" ...
$ : chr [1:4] "OBS_STATUS" "" "Observation" "Comment"
$ : chr [1:4] "OBS_COMMENT" "" "Observation" "Comment"
But I do not know how to retrieve as column names the first part of each character chain