I am working with some headers and I need to remove parenthesis in the headers but only where is nothing inside but to keep the others if it has the unit of measure. e.g.
"Sample_No ()" - Sample_No
"SOC (%)" - "SOC (%)"
Example
>Solution :
Using gsub you could do:
header <- c("Sample_No ()", "SOC (%)")
gsub("\\s*\\(\\)", "", header)
#> [1] "Sample_No" "SOC (%)"
