我有以下数据框:
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))
然后我收到警告消息:
强制性引入的不适用
并且用逗号替换具有NA的值。我该如何解决这个问题?
答案 0 :(得分:2)
db$c <- as.numeric(gsub(",","",db$c))