0

I have the following dataframe:

a <- c(1,2,3,4)
b <- c("Product 1","Product 2","Product 3","Product 4")
c <- c("1,004","1,80","3","18")

db <- data.frame(a,b,c)

db$c <- as.numeric(as.character(db$c))

Then I get the warning message:

NAs introduced by coercion

And the values having a comma are replaced with NAs. How can I solve this issue?

Sotos
  • 47,396
  • 5
  • 31
  • 61
Afke
  • 787
  • 1
  • 8
  • 19

1 Answers1

2
db$c <- as.numeric(gsub(",","",db$c))
Pete
  • 598
  • 5
  • 14