R arithmetic operations
kodingwindow@kw:~$ R ... Addition > 1 + 1 [1] 2 Subtraction > 1 - 1 [1] 0 Multiplication > 10 * 10 [1] 100 Division > 1 / 0 [1] Inf Power or exponent > 0 ** 0 [1] 1 > 0 ^ 0 [1] 1 Remainder > 10 %% 3 [1] 1
R sqrt() function
Square root of a number > sqrt(25) [1] 5 > sqrt(2) [1] 1.414214
R sum() function
> 1:10 + 11:20 [1] 12 14 16 18 20 22 24 26 28 30 Sum of sequence 1 to 10 > sum(1:10) [1] 55
R mean() and median() functions
> mean(1:10) [1] 5.5 > median(1:10) [1] 5.5
R identical() function
> identical(1,1) [1] TRUE > identical(1,1.0) [1] TRUE > identical(0 ^ 0,0 ** 0) [1] TRUE
R factorial() function
Factorial of a number > factorial(0) [1] 1 > factorial(100) [1] 9.332622e+157
R trigonometric function
> pi [1] 3.141593 > sin(30) [1] -0.9880316 > tan(90) [1] -1.9952
Advertisement