问题
I have a large dataframe with long column names in it. I would like to shorten the columnnames by dropping characters before a colon sign (:), the sign is present in every column name in the dataframe columns. Looking for a way to perform this on a dataframe??
回答1:
Perhaps (third try):
names(df) <- sub("^(.+[:])([^.]+)$", "\\2", names(df))
来源:https://stackoverflow.com/questions/26807430/r-how-to-remove-characters-from-long-column-names-in-a-data-frame