Because, as.numeric() can't be used when your character having commas, dollar signs, or even empty strings.
As an example in my dataset in the price column the class is getting as character. But I want to convert it into numeric. When I directly used as.numeric() I got an warning as 'NAs introduced by coercion'. Then I removed the spaces in the price column -->
gold_ds$Price <- gsub(",", "", gold_ds$Price)
and then did -->
gold_ds$Price <- as.numeric(gold_ds$Price).
It succefully worked for me in R.