r - 将“1000,00+”值转换为 R 中的数字会给出警告“强制引入的 NA”?
问题描述
我的数据集有“安装”列,其值如 (“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))
推荐阅读
- jquery - laravel 8中的依赖下拉列表
- r - 遍历基于 tidyverse/rlang 的函数的输入值
- simulation - 如何使用有限数量的卡车重新创建装载卡车箱?
- jquery - 未捕获的错误:此元素上已安装颜色选择器
- node.js - 尝试构建 Angular 构建时收到错误
- php - 如何在 Laravel 5.7 中重定向 //?
- python - Coursera-dl 没有下载课程命令提示符 Windows
- python - 在 gcc 中链接 Python 3.8 库时出现问题
- django - 如何在 Django 频道中实现多聊天
- c - 什么时候写“0 - x”而不是“-x”有用?