Experiment 1-Basic Maths & Stao Operations in R

Prudhwi Raj Krishna V

11-04-2020

Aim

Execute basic mathematical; and statistical operations in R

Algorithm

Step1: Create R code chunks

Step2: Write math expressions

Step3: Run the chunk codes

Step4: Report the results

R-code

In this experiment basic mathematical operations will be tested using R

 #addition
a=10;
b=30;
a+b;
## [1] 40
   #subtraction
    x=425;
    y=345;
    x-y;
## [1] 80
#multiplication
    a1=34;
    a2=5.4;
    s=prod(a1,a2);
    paste0("Product of ",a1," and ",a2, " is ",s);
## [1] "Product of 34 and 5.4 is 183.6"
 #division
    c=32;
    d=6;
    qu=c/d;
    qu;
## [1] 5.333333
#reminder
    rem=c%%d;
    rem;
## [1] 2
#divisor calculation
    r=32;
    s=2;
    d=r%/%s;
    d;
## [1] 16
#power of number
   a=5;
    b=5^2;
    b;
## [1] 25
    v=1:10;
    v^10;
##  [1]           1        1024       59049     1048576     9765625    60466176
##  [7]   282475249  1073741824  3486784401 10000000000
#n*array
 ar=c(1,5,7,9,21);
    5*ar;
## [1]   5  25  35  45 105
#2 diff. array multiplication
    br=c(1,4,1,2,8);
    ar;br;ar*br;
## [1]  1  5  7  9 21
## [1] 1 4 1 2 8
## [1]   1  20   7  18 168
#round down
 floor(3.1427)
## [1] 3
#round up
  ceiling(.6879)
## [1] 1
#factorial
 factorial(10)
## [1] 3628800

To find \(nCr=\frac{n!}{r!(n-r)!}\)

#Combination
choose(5,3)
## [1] 10

Permutation can be found using :\(^nP_r=n\times(n-1) \times \cdots \times (n-r+1)\)

#Permutation
prod(10:(10-4+1))
## [1] 5040

Result