Assignment1 a. Create two matrices b. Select two columns c. Use cbind to create a new matrix
> x<- c(19,10,15,100,27,45,51,73,62)
> dim(x)<- c(3,3)
> x
[,1] [,2] [,3]
[1,] 19 100
51
[2,] 10 27
73
[3,] 15 45
62
> mat2<- c(32,48,01,05,10,12,15,18,21)
> dim(mat2)<- c(3,3)
> col1<- mat2[ ,1]
> col1
[1] 32 48 1
> z<- cbind(col3,col1)
> z
col3 col1
[1,] 51 32
[2,] 73 48
[3,] 62 1
Assignment2 a. Multiply matrix1 and matrix2
> mult<- x%*%mat2
> mult
[,1] [,2] [,3]
[1,] 5459 1707 3156
[2,] 1689 1196 2169
[3,] 2702 1269 2337
Assignment3 a. Regression of NSE downloaded data 01/12/12-31/21/12
> data2<- read.csv(file.choose(),header=T)
> reg1<- lm(High~Open,data=data2)
> reg1
Call:
lm(formula = High ~ Open, data = data2)
Coefficients:
(Intercept)
Open
1578.3358 0.7355
Assignment 4: a. Plot a Normally Distributed Data
x<-seq(-10,10,by=0.1)
y<-dnorm(x, mean=0, sd=12)
plot(x,y, type="l")

No comments:
Post a Comment