saving . . . saved Assignment has been deleted. Assignment has been hidden .
Assignment
Title
Question
matrixB=matrix(nrow=4,ncol=2,data = c(9,10,11,12,13,14,15,16))
print(matrixB)
     [,1] [,2]
[1,]    9   13
[2,]   10   14
[3,]   11   15
[4,]   12   16

Sir i have doubt if i type the above coding i am getting the above solution but the assignment was to create two vectors so i have the coding as

 x=c(9,10,11,12)
y=c(13,14,15,16)
matrixB=matrix(nrow=4,ncol=2,x,y)
 print(matrixB)
     [,1] [,2]
[1,]    9   10
[2,]   11   12
[3,]    9   10
[4,]   11   12

i am getting like above solution , pls correct me sir

R Creating-Matrices-using-Data-Frames 10-11 min 50-60 sec 15-08-21, 11:27 a.m. kajalmeena

Answers:

You need to pass "x" and "y" together as a single argument to the function "matrix()." You can do that using the "c()" function. The correct code is "matrixB=matrix(nrow=4,ncol=2,c(x,y))."


15-08-21, 11:49 a.m. chrl3hr5@gmail.com


Log-in to answer to this question.