-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperators.R
46 lines (41 loc) · 1.11 KB
/
Operators.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
##### Assign Variable #####
stat.score <- 18
stat.score = 19
assign("stat.score",20)
stat.score #print value
##### Arithmetic Operators #####
10+5 #Addition
10-5 #Subtraction
10*5 #Multiplication
10/5 #Division
10^5 #Exponentiation
format(10**5,scientific=FALSE) #Exponentiation
10%%3 #Modulus
10%/%3 #Integer Division
abs(-5) #Absolute
log(2) #Natural Log
log(2,base=10) #Log
exp(5) #Exponential
factorial(5) #Factorial
pi #PI
1/0 #Positive Infinity
-1/0 #Negative Infinity
Inf/Inf #NaN (Not a Number)
NA #NA (Not Available)
is.na(NA)
is.nan(NaN)
##### Logica Operators #####
5>2 #greater than
5>=2 #greater than equal to
5<2 #less than
5<=2 #less than equal to
5==2 #exactly equal to
!(TRUE) #Logical NOT Operator
TRUE|FALSE #Logical OR Operator
TRUE&FALSE #Logical AND Operator
##### Vectorized Operators #####
student.stat.marks <- c(20,18,19,20,20)
student.psych.marks <- c(18,19,19,18,20)
student.psych.marks <- student.psych.marks+1
student.total.marks <- student.stat.marks+studnet.psych.marks
mean(student.total.marks)