I am reading in a bunch of CSVs that have stuff like \"sales - thousands\" in the title and come into R as \"sales...thousands\". I\'d like to use a regular expression (or o
Rich Scriven had the answer:
Define
colClean <- function(x){ colnames(x) <- gsub("\\.\\.+", ".", colnames(x)); x }
and then do
a <- colClean(a)
to update a
names(a) <- gsub(x = names(a), pattern = "\\.", replacement = "#")
you can use gsub
function to replace .
with another special character like #
.