0
votes

I Have dataset like below which I am trying to convert column "Installs" to numeric, my codes are like below:

Original Dataset

My Codes:-

Data$Installs<-substr(Data$Installs,1,nchar(Data$Installs)-1)
Data$Installs<-gsub(",","",gsub("\\s+","",Data$Installs))
Data$Installs<-as.numeric(Data$Installs)

after the code I get below

This is the result I get Any help?

1
Please don't link images of data or results. - Elin

1 Answers

1
votes

From what I can see, you need only to remove commas and a possible trailing plus sign. So, the following should work:

Data$Installs <- as.numeric(gsub("[+,]", "", Data$Installs))

You might want to create a new column though and keep the original one.