A user wants to use runif() to create a 4 by 5 matrix consisting of 20 random numbers (4*5=20). How to do that?

981    Asked by Deepalisingh in Data Science , Asked on Dec 10, 2019
Answered by Deepali singh

Let us create a matrix consisting 20 random numbers of size 4 by 5

ranmat <- matrix(runif(20,min=0,max=100),nrow = 4)

ranmat

         [,1] [,2] [,3] [,4] [,5]

[1,] 96.30242 2.461368 31.81810 41.37243 23.30341

[2,] 90.22990 47.779597 23.16258 36.88455 46.59625

[3,] 69.07053 75.845954 14.28000 15.24447 26.59726

[4,] 79.54674 21.640794 41.45463 13.88061 85.78277



Your Answer

Interviews

Parent Categories