0

I'm generating networks using the rgnm function from the sna package. E.g.

int_mat <- rgnm (1,10,33)

Is there a method that I can use to produce a non-square matrix (e.g. 10 x 11 matrix) using this or another function?

Thanks!

unknown
  • 853
  • 1
  • 10
  • 23

1 Answers1

1

This seems to do what you want.

n_rows <- 10; n_cols <- 11; n_1s <- 33
elements <- rep(0, n_rows* n_cols)
elements[sample(1:length(elements), 33)] <- 1
int_mat <- matrix(elements, nrow=n_rows, ncol=n_cols)
kangaroo_cliff
  • 6,067
  • 3
  • 29
  • 42