-1
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
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66

2 Answers2

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

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
  • 874,273
  • 37
  • 540
  • 662