I am trying to convert a factor vector into numeric value without any changes in the value.
I looked up and found out some functions like
bonds1 <- as.numeric(as.character(bonds$price))
Warning message:
NAs introduced by coercion
bonds1 <- as.numeric(levels(bonds$price)[bonds$price])
Warning message:
NAs introduced by coercion
but as it is shown above, warning signs keep coming up. Any ideas on why this is not working?
[figured it out]
It was the commas in bonds$price
bonds$price <- as.numeric(gsub(",","",bonds$price))