Professional Documents
Culture Documents
Shahima I071 Lab1 ML
Shahima I071 Lab1 ML
LAB 1- Basics Of R
Code:-
a=20
b=30
c=a+b
x<- c(1,3,2,5)
length(x)
x=c(1,2,3)
y=c(4,5,6)
z=x+y
z
ls()
rm(c)
ls()
x=matrix(data=c(1,2,3,4), nrow=2, ncol=2)
x
matrix(c(1,2,3,4,5,6,7,8,9),3,3, byrow=TRUE)
sqrt(x)
x^2
x=rnorm(50)
y=rnorm(50)
cor(x,y)
var(x)
mean(y)
sd(y)
sqrt(var(x))
set.seed(1111)
x=rnorm(100)
set.seed(1111)
y=rnorm(100)
plot(x,y)
plot(x,y,xlab=" this is the x-axis",ylab=" this is the y-axis", main=" Plot of X vs Y")
pdf ("Figure.pdf")
plot(x,y,col ="green")
dev.off()
x=seq(1 ,10)
x
y=1:10
y
x=seq(-pi ,pi ,length =50)
x
x=y
f=outer(x,y,function (x,y)cos(y)/(1+x^2))
persp(x,y,fa)
A[2,3]
A[c(1,3) ,c(2,4) ]
A[1:3 ,2:4]
A[1:2 ,]
A[ ,1:2]
A[1,]
A[-c(1,3) ,]
dim(A)
iris=read.table ("C:/Users/Shahima/Desktop/SEM5/DWM/LABS/LAB1/iris.data")
fix(iris)
dim(iris)
names(iris)