Generate Matrix with i.i.d. Normal Random Variables in R (2 Examples) | matrix() & rnorm() Functions

preview_player
Показать описание
R code of this video:

N_row <- 10 # Define number of rows & columns
N_col <- 3

my_mat <- matrix(rnorm(N_row * N_col), # Create random matrix
ncol = N_col)
my_mat # Print random matrix

my_df # Print random data frame

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

hello! I have a similiar matrix and i want to find the mean(row)/var(row) for each row of my matrix. how do I do this? or should I set a different type of matrix to start with?

cherylsusanv
Автор

i would like to use a random matrix and the solution of it but only the general code using rnorm or runif

Skywalker-vckc
Автор

hello
i try to run the code but there is error

Skywalker-vckc
welcome to shbcf.ru