Reputation: 23
I Have dataset like below which I am trying to convert column "Installs" to numeric, my codes are like below:
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?
Upvotes: 0
Views: 191
Reputation: 520898
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.
Upvotes: 1