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
  • 51,121
  • 6
  • 32
  • 66
Afke
  • 899
  • 2
  • 10
  • 21

1 Answers1

2
db$c <- as.numeric(gsub(",","",db$c))
Pete
  • 600
  • 1
  • 6
  • 16