vini.m.oliveira
vini.m.oliveira

Reputation: 109

Remove dots from strings in R

I want to remove all dots in a df column of prices, all integers. The data:

df <- data.frame(price = c(1.800.000, 900.000, 1.500.000, ...))

I want:

price
1800000
900000
1500000

I have tried gsub('.', '', as.character(df$price)), but I got only empty strings.

What could I do?

Upvotes: 1

Views: 1537

Answers (1)

Mohamed Desouky
Mohamed Desouky

Reputation: 4425

Try this

gsub('\\.', '', as.character(df$price))

Upvotes: 3

Related Questions