Error in **** : non-numeric argument to binary operator
Error in **** : non-numeric argument to binary operator
目录
Error in **** : non-numeric argument to binary operator
问题:
解决:
完整错误:
问题:
想要生成新的数据列,基于已有数据列的差,但是其中一个作差的数据列不是数值型,不是数值怎么作差,OK出问题了。
#create data frame
df <- data.frame(period = c(1, 2, 3, 4, 5, 6, 7, 8),sales = c(14, 13, 10, 11, 19, 9, 8, 7),returns = c('1', '0', '2', '1', '1', '2', '2', '3'))#view data frame
df#attempt to create new column called 'net'
df$net <- df$sales - df$returns
解决:
#class查看数据类型
#display class of 'sales' column
class(df$sales)[1] "numeric"#display class of 'returns' column
class(df$returns)[1] "character"
#as.numeric转换之后再作差
#create new column called 'net'
df$net <- df$sales - as.numeric(df$returns)#view updated data frame
df
完整错误:
> #create data frame
> df <- data.frame(period = c(1, 2, 3, 4, 5, 6, 7, 8),
+ sales = c(14, 13, 10, 11, 19, 9, 8, 7),
+ returns = c('1', '0', '2', '1', '1', '2', '2', '3'))
>
> #view data frame
> df
period sales returns
1 1 14 1
2 2 13 0
3 3 10 2
4 4 11 1
5 5 19 1
6 6 9 2
7 7 8 2
8 8 7 3
>
> #attempt to create new column called 'net'
> df$net <- df$sales - df$returns
Error in df$sales - df$returns : non-numeric argument to binary operator
Error in **** : non-numeric argument to binary operator相关推荐
- R语言报错 Error in y + 1 : non-numeric argument to binary operator 解决记录
因为花了2天半才解决,中间痛苦的寻找,记录一下解决的流程与经验 文章目录 报错信息: 报错原因: 原代码: 报错原因解析: 1. 转置后数据类型变为character,因为numeric数据中存在ch ...
- R中报错Error in mut[, pos] - 1 : non-numeric argument to binary operator
数据不是数值型,转换成数值型即可解决问题 as.numeric() > sigs.input=mut.to.sigs.input(mut.ref =sample.mut.ref ,sample. ...
- R语言构建随机森林模型错误解决:Error in y - ymean : non-numeric argument to binary operator
R语言构建随机森林模型错误解决:Error in y - ymean : non-numeric argument to binary operator 目录 R语言构建随机森林模型错误解决:Erro ...
- R语言报错 non-numeric argument to binary operator
R语言对数据框的数据进行求和与平均值,直接计算报错,原代码如下: mydata1 <- mutate(mydata1,sum = sale2015 + sale2016 + sale2017 + ...
- windows安装pycocotools错误:cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
在安装基于keras.tensorflow实现的Mark RCNN(https://github.com/matterport/Mask_RCNN),要运行其中的demo.ipynb时,需安装pyco ...
- 关于R语言报错:invalid argument to unary operator(一元运算符的无效参数)---ggplot2画图问题--解决Monte Carlo模拟输出
目录 背景 我的操作(错误 解决问题过程: 1)查找 2)尝试将画图等过程从函数中移出来 3)尝试将+geom_line(aes(y=h_mean-sqrt(h_var))移入到前面的一行中去 结果 ...
- 日常生活小技巧 -- “Error: Encountered an improper argument”的解决方法
使用keil5.25兼容版本的,在debug过程中修改代码和打断点,再退出debug马上就出现该问题:Error: Encountered an improper argument. 解决方法: 工程 ...
- ERROR: Unrecognized command line argument: #39;use#39;
Unrecognized command line argument: 'use' gvm- -GoLang语言多版本管理工具 基础环境 centos6.5 报错内容 gvm在命令行以外的任何地方调用 ...
- QT “error: error writing to -: Invalid argument”
我所出现的问题源自不同系统下目录的写法:在linux中我们写路径一般使用斜杠/,然而在Windows下为反斜杠\. 我在Windows下使用下面的写法Qt会提示error: error writing ...
最新文章
- 《黑客与画家》读后感:你对技术一无所知(一些金句)
- odoo12 日历模块_odoo12
- .net 5 正式版_ASP.NET Core 3时代全新开启,DevExpress ASP.NET增强Data Grid
- vue中打印表格功能(重点是表格制作)
- 韩立刚计算机网络——第三章:数据链路层
- C语言 实验7-3-5 输出大写英文字母 (15分)
- 用Python做的整蛊小程序——整点阴间的东西
- mc服务器图标修改,高版本配置文件修改(添加,修改交易)
- 性能工具之Java分析工具BTrace入门
- Qt 自定义标题栏,最小化、最大化、关闭窗口,双击最大化,鼠标拖动等效果实现
- MIMO-OFDM系统原理及其关键技术
- 解决笔记本IPS屏幕发黄问题
- Oracle安装和配置
- STM32深入实践教程目录
- 计算机最学生写作的影响,计算机对学生英语写作影响的元分析
- 用PyTorch来实现手写体数字识别
- 4.9 朗斯基行列式
- 我使用的安卓软件名单
- Mac m1恢复出厂设置
- 2020年8月工作月报
热门文章
- 架构中的一切都是权衡
- 线下活动【深圳】用Leangoo做Scrum敏捷开发实战课(免费)
- 网络负载均衡相关技术-第四层交换功能
- C 关于页面刷新和combobox的使用
- 26 history对象
- Python中的生产者与消费者模式(转载)
- html5 css3雪花效果,HTML5 | CSS3水晶皇冠雪花形状
- discuz sitemap.php,discuz制作门户的百度sitemap
- DisARM:用于3D目标检测的位移感知关联模块(CVPR2022)
- CVPR2021 | PAConv:一种位置自适应卷积,点云分类、分割任务表现SOTA