A little more knowledge on matrices and some other applications of 'R'.
Question 1 : Column Binding
Command:
mat1<-c(5,2,4,3,6,4,6,7,3,11,9,1,10,4,2,2)
dim(mat1)<-c(4,4)
mat2<-c(4,2,3,5,2,2,1,6,3,6,4,3,2,8,9,11)
dim(mat2)<-c(4,4)
sel1<-mat1[ ,3]
sel2<-mat2[ .2]
matbind<-cbind(sel1,sel2)
matbind
Question 2 : Matrix Multiplication
Command:
mat1<-c(5,2,4,3,6,4,6,7,3,11,9,1,10,4,2,2)
dim(mat1)<-c(4,4)
mat2<-c(4,2,3,5,2,2,1,6,3,6,4,3,2,8,9,11)
dim(mat2)<-c(4,4)
matprd<-mat1%*%mat2
matprd
Question 1 : Column Binding
Command:
mat1<-c(5,2,4,3,6,4,6,7,3,11,9,1,10,4,2,2)
dim(mat1)<-c(4,4)
mat2<-c(4,2,3,5,2,2,1,6,3,6,4,3,2,8,9,11)
dim(mat2)<-c(4,4)
sel1<-mat1[ ,3]
sel2<-mat2[ .2]
matbind<-cbind(sel1,sel2)
matbind
mat1<-c(5,2,4,3,6,4,6,7,3,11,9,1,10,4,2,2)
dim(mat1)<-c(4,4)
mat2<-c(4,2,3,5,2,2,1,6,3,6,4,3,2,8,9,11)
dim(mat2)<-c(4,4)
matprd<-mat1%*%mat2
matprd
Question 3 : Linear Regression Model
Data used:
Command:
nse<-read.csv(file.choose(),header=T)
open<-nse[ ,2]
high<-nse[ ,3]
reg<-lm(high~open,data=nse)
reg
Question 4 : Noraml Distribution
Command:
x<-seq(0,200)
y<-dnorm(x,mean=100,sd=20)
plot(x,y,type="l",col="red")
No comments:
Post a Comment