I have a variable in a data frame which consists of either 5 or 6 digits/characters. Those values in the variable with 5 digits are all numbers e.g. 27701 those with 6 digits however all have a character 'C' preceding the numbers e.g. C22701.
How can I replace the 'C' characters with 999 for example?
I have tried:
replace(data$varname,'C',999) Any ideas folks?
data$varname <- gsub('C', '999', data$varname)maybe? Ifvarnameis afactor, it could cause problems thoughCharacter?Factor?Numeric?