head(data$`Brand Value`)
#[1] $145.3 B $69.3 B $65.6 B $56 B $49.8 B $39.5 B
#77 Levels: $10.4 B $10.5 B $10.6 B $11 B ... $9.6 B
data$`Brand Value`<-as.numeric(as.character(data$`Brand Value`))
#Warning message:
#NAs introduced by coercion
Asked
Active
Viewed 93 times
-1
Rui Barradas
- 57,195
- 8
- 29
- 57
-
1None of those values is coercible to numeric. They all have non-digit characters like `$` or `B`. – Rui Barradas Jun 27 '20 at 17:52
-
Try `data$``Brand Value`` – Rui Barradas Jun 27 '20 at 17:57
2 Answers
0
If you notice, your data has a dollar sign and a "B" letter (Billion) on it (which is a character), that's the reason why you can't coerce it into a numeric data. You need to get rid of any characters or symbols if you want to change the data type into numeric. However, if you want to add a dollar sign in front of numeric data, you might want to refer to this link
Matthew Farant
- 72
- 1
- 8
0
We can use parse_number from readr which will extract only the numeric substring from the column and convert the class
library(readr)
data$`Brand Value` <- parse_number(data$`Brand Value`)
akrun
- 789,025
- 32
- 460
- 575