首页 > 解决方案 > 如何修复此意外令牌“!=”错误

问题描述

我不知道我做错了什么,但我以前在互联网上找不到答案。也许你们中的任何人都可以帮助我修复错误。

它说意外令牌'!='。以下是代码:

args <- commandArgs(trailingOnly = TRUE) 
if((!= is.null(args[1])) && (!=is.na(args[1]))) filename = args[1] 

标签: runexpected-token

解决方案


你应该使用if((!is.null(args[1])) && (!is.na(args[1]))) filename = args[1]

!=运算符(不等于)用于左侧的测试对象和右侧的预期值if((is.null(args[1]) != TRUE)


推荐阅读