运算

基本运算

R 中 character 是可以比较大小的。
R uses the alphabet to sort character strings.
首字母在后面的大。
大写字母在前, 小写字母在后。

> "Hello" > "Good"
[1] TRUE

>  TRUE > FALSE
[1] TRUE

logic operator

1. 元素

and or not
& | !

2. 向量

> c(TRUE, TRUE, FALSE) & c(TRUE, FALSE, FALSE)
[1]  TRUE FALSE FALSE
> c(TRUE, TRUE, FALSE) | c(TRUE, FALSE, FALSE)
[1]  TRUE  TRUE FALSE
> !c(TRUE, TRUE, FALSE) 
[1] FALSE FALSE  TRUE

&& double ampersand operation
|| double vertical bar
only examines the first element of each vector.

> c(TRUE, TRUE, FALSE) && c(TRUE, FALSE, FALSE)
[1] TRUE

You’ll need to use the && sign here. This causes the evaluation of the condition to halt as soon as the result of the condition is known; if logs[[i]]$success is TRUE, it’s certain that the condition will be FALSE, so the next comparison is not evaluated anymore.

if (logs[[i]]$success == FALSE && logs[[i]]$details$location == "waste")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值