A.JO
A.JO

Reputation: 235

Fill a matrix with only pair values

I'm trying to fill a matrix of 12 rows and 15 cols with the pair values(2,4,6,8,...) sort by row. I tried this command line:

x=c(2:2:360,nrow=12,ncol=15,byrow=TRUE)

But it gives me (2,3,4,5,6,7,8,9,...)

For a matrix of two rows and 5 cols:

[2,    4,   6,   8,  10

 12,  14,  16,  18,  20]

Thank you

Upvotes: 0

Views: 66

Answers (1)

Ole Tange
Ole Tange

Reputation: 33748

Try this:

x=matrix(1:180*2, ncol = 15, byrow = TRUE)

Upvotes: 1

Related Questions