I am trying to replace last 3 000 with K in a column in the dataframe
eg:
data <- data.frame(abc = c(1000, 100000, 450000))
abc <- 1000
then abc <- 1K
if
abc <- 100000
then abc <- 100K
gsub or regex replaces the first 3 zeroes
I tried this:
lapply(data$abc, gsub, pattern = "000", replacement = "K", fixed = TRUE)
Also, how can I make it work on an interval like :
data <- data.frame(abc = c("150000-250000", "100000-150000", "250000K+"))