R Program Record 2023
R Program Record 2023
Marks Remarks
No Date Title Page Awarded
no
1 To Illustrate basic 01
arithmetic in R
EXPERIMENT-1
AIM :
PROGRAMME:
a=4
b=2
add=a+b
sub=a-b
div=a/b
mul=a*b
int_div=a%/%b
modulus=a%%b
exponent=a^b
print(paste(“addition:”,add))
print(paste(“subtraction:”,sub))
print(paste(“multiplication:”,mul))
print(paste(“division:”,int_div))
print(paste(“modulus:”,modulus))
print(paste(“a power b:”,exponent))
OUTPUT:
[1]”addition:6”
[1]“subtraction:2”
[1]“division:2”
[1]“multiplication:8”
[1]“integer division:2”
[1]“modulus:0”
PAGE NO : 02
EXPERIMENT - 2
AIM:
PROGRAMME:
#assignment of variables…
#their are five types of assignment operators
.#1.left assignment
#2.left assignment(“=”not recommended)
#3.right assignment=>
#4.left lexicographic assignment(advanced)
#5.right lexicographic assignment(advanced)
X<-3
Y=5
Z->z
A<<-1
2->>b
Print(x)
Print(y)
Print(z)
Print(a)
Print(b)
OUTPUT:
Print(x)
[1] 3
Print(y)
[1]5
Print(z)
[1]7
Print(a)
PAGE NO : 03
[1]1
Print(b)
[1]2
PAGE NO : 04
EXPERIMENT - 3
AIM:
PROGRAMME:
X<-123L#integer
Print(class(x))
X<-TRUE
Print(class(x))
X<-63
Print(class(x))
X<-63.5
Print(class(x))
X<-3+2;
Print(class(x))
X<-”hello”
Print(class(x))
OUTPUT:
[1] ”integer”
[1] ”logical”
[1] “numerical”
PAGE NO : 05
[1] “complex”
[1] “character”
PAGE NO : 06
EXPERIMENT - 4
AIM :
PROGRAM:
#creating a vector
Vec<-c(1:10)
Vec
Vec<-c(1,2,3,4,5)
Vec
Vec<-c(TRUE,FALSE)
Vec
OUTPUT :
Creatng a vector
> vec <_c(1:10)
>vec
[1] 1 2 3 4 5 6 7 8 9 10
>vec <-c(1,2,3,4,5)
>vec
[1] 1 2 3 4 5
>vec <-c(TRUE,FALSE)
>vec
[1] TRUE,FALSE
PAGE NO : 07
EXPERIMENT - 5
AIM :
PROGRAM :
OUTPUT :
1 2 3
4 5 6
7 8 9
2 2 2
2 2 2
2 2 2
1 1 1
0 0 0
0 0 0
1 1 1
1 1 1
1 1 1
PAGE NO : 08
EXPERIMENT – 6
AIM :
PROGRAM :
M<-matrix(c(1:9),3,3,TRUE)
Print(M)
B<-rbind(M,c(2,4,5))
Print(c)
OUTPUT :
1 2 3
4 5 6
7 8 9
1 2 3
4 5 6
7 8 9
10 11 12
1 2 3 2
4 5 6 4
7 8 9 7
PAGE NO : 09
EXPERIMENT - 7
AIM :
PROGRAM :
M <-matrix(c(1:9),3,3,TRUE)
M[1,2]
M[2,3]
M[,2]
M[2,]
OUTPUT :
> M[1,2]
[1] 1
> M[2,3]
[1] 1
> M[,2]
[1] 1 1 1
> M[2,]
[1] 1 1 1
PAGE NO : 10
EXPERIMENT - 8
AIM :
PROGRAM :
A <-matrix(c(1:4),2,2,TRUE)
B <-matrix(c(5:8),2,2,TRUE)
Print(A+B)
Print(A-B)
Priint(A*B)
Print(B/A)
OUTPUT :
> (A+B)
[,1] [,2]
[1,] 6 8
[2,] 10 12
> (A-B)
-4 -4
-4 -4
> (A*B)
PAGE NO : 11
5 12
21 32
> (B/A)
5.00000 3
2.33333 2