Part 1 运算
1. 算术运算符
+-*/
%%求余
%/%求商
^指数
2. 关系运算符
大小关系比较,结果为布尔值
!=不等于
3. 逻辑关系
返回布尔值,其中,大于1的数字为True,返回True也为True
& and
| or
! not
&& and the first
|| or the first
4. 赋值运算符
左分配
左箭头,等于号,<<-
右分配
右箭头,->>
5. 其他特殊运算符
:区间
%in% 返回布尔值
%*% 矩阵与转置矩阵相乘
Part 2 决策
1. if, else, else if
if(boolen_judgement){
if True commands
} else if (boolen_judgement){
if True commands
}
else {
commands
}
single if False statement
if, else if, else in sequence; the following two are not necessary.
2. switch
function: switch(expression, v1, v2, ...) #expression, list,根据值列表测试相等性
expression: 整数(位置匹配),字符串(元素匹配)
多个匹配返还第一个
网友评论