I have a dataset where some of the columns have special characters. I want to clean this dataset and remove these special characters from all the columns that have them. A subset of the column names is below:
Crorf64[,1]
ADF3
DF41c[,1]
AGGF3[,1]
SRGHJ
My desired output is:
Crorf64
ADF3
DF41c
AGGF3
SRGHJ
My attempt to remove the parts of the column names with the special characters is below, using this answer as a guide https://stackoverflow.com/a/37801926/17054028:
training%>%
mutate(col=str_remove_all(col,"[.*"))
I get an error when I use this:
Error in `mutate()`:
! Problem while computing `col = str_remove_all(col, "[.*")`.
Caused by error in `stri_replace_all_regex()`:
! argument `str` should be a character vector (or an object coercible to)
Any other alternatives to perform this task are welcome.