【发布时间】:2020-06-27 17:25:08
【问题描述】:
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
【问题讨论】:
-
这些值都不能强制转换为数字。它们都有非数字字符,例如
$或B。 -
试试
data$``Brand Value``<-as.numeric(gsub("[^\\.[:digit:]]", "", x))。
标签: r data-manipulation