Data type Conversion



I have a column in my data which shows percentage of bounce rate but it is in character mode. How to convert the character mode into numeric mode so that i can divide it with any number




I tried but then it is converting it in NA values


please share few rows of the column which shows percentage of bounce rate, to debug


Analytics All Web Site Data Location.csv (792 Bytes)

here is that file


Hello Siddhant,

There are % symbol in your 'Bounce Rate" and other columns. You will have to strip out the % symbol before converting it to numeric.

Below is the code for that. Hope it helps.


data = fread(‘Analytics All Web Site Data Location.csv’, stringsAsFactors=F)


fixing the colnames
replacing space and \ by _

colnames(data) <- gsub(’\s+|\/’, ‘_’, colnames(data))

Bounce rate is read as character and contains %
need to clean % and convert to numeric.

data$Bounce_Rate <- as.numeric(gsub(’\%’,"",data$Bounce_Rate))


you can process the other columns similarly :slight_smile:


ok…Thank u so much. Can u tell me one more thing that which technique to use to make predictive imputation model. I am amateur currently


well it depends … missing value imputation itself is a topic in itself … if you want to go with imputation with predictive model … you can use any tree based model (random forest for example) …


ohh!! Thank u so much…