Input the following vector into R V=c(300,131,38,41,27,66,48,160,156,133,102,102
ID: 3354569 • Letter: I
Question
Input the following vector into R V=c(300,131,38,41,27,66,48,160,156,133,102,102,200,134,136,149,187,190,224,128,209,141,168,164)V=c(300,131,38,41,27,66,48,160,156,133,102,102,200,134,136,149,187,190,224,128,209,141,168,164).
Step 1 Create a 4 by 6 matrix M with the elements in V by filling the columns of M first (i.e. first column, second columns, etc) Step 2 Let X1 = M2,3 (entry of M at Row 2 and Column 3), x2 M3,1 , and X3 = M45 What is the R command to assign M2.3 to xj ? Type without any spaces! xI Calculatee A. No B. Yes This can be a very common mistake in this courseExplanation / Answer
The complete R snippet is as follows
V=c(300,131,38,41,27,66,48,160,156,133,102,102,200,134,136,149,187,190,224,128,209,141,168,164)
mymat<- matrix(V,nrow = 4,ncol = 6)
print(mymat)
## x1
x1 <- mymat[2,3]
x2 <- mymat[3,1]
x3 <- mymat[4,5]
x1square = sum(x1^2 + x2^2 + x3^2)
x1wholesquare = (sum(x1 + x2 + x3))^2
print(x1square)
print(x1wholesquare)
The results are
> print(x1square)
[1] 35517
> print(x1wholesquare)
[1] 89401
Hence the results are not same.