Displaying 1 result from an estimated 1 matches for "rowvec".
Did you mean:
rawvec
2013 Oct 15
2
A 'good' way to build a matrix from a sequence of integers?
...3 = matrix(vec1x3, c(length(vec1x3),1))
m1x3
# [,1]
# [1,] 1
# [2,] 2
# [3,] 3
# >
# That was easy.
# Next I want to expand from a 1 x 3 matrix to a 2 x 9 matrix
# which contains all combinations of 1:3
# So the first 4 rows would look like this:
# 1 1
# 1 2
# 1 3 I call this a rowvec
# 2 1
# My first idea is write a loop like this:
for (i in 1:3) {
for(j in 1:3) {
rowvec = c(i,j)
# Place rowvec in matrix
}
}
# I'm curious if a skilled R-person would do it differently?
[[alternative HTML version deleted]]