在 R 中将“1000,00+”值转换为数字会给出警告 "NAs introduced by coercion"?
Converting "1000,00+" values to numeric in R gives warning "NAs introduced by coercion"?
我的数据集包含“安装”列,其值类似于(“5,000+”、“10,000+”、....)
当我尝试将其转换为数字时,它给出了 NA 值并出现错误:
df <- as.numeric(gsub(",","",df_dataset$Installs))
Warning message:
NAs introduced by coercion
我想同时替换“+”和“,”符号。我怎样才能做到这一点?
尝试删除所有非数字字符:
Installs_Numeric <- as.numeric(gsub("[,+]+", "", df_dataset$Installs))
我的数据集包含“安装”列,其值类似于(“5,000+”、“10,000+”、....)
当我尝试将其转换为数字时,它给出了 NA 值并出现错误:
df <- as.numeric(gsub(",","",df_dataset$Installs))
Warning message:
NAs introduced by coercion
我想同时替换“+”和“,”符号。我怎样才能做到这一点?
尝试删除所有非数字字符:
Installs_Numeric <- as.numeric(gsub("[,+]+", "", df_dataset$Installs))