Reputation: 111
I am trying to create a matrix like so:
x1 <- rbern(1000,.5)
x2 <- (1-x1)
head(x2)
head(x1)
M <- cbind(x1,x2)
M
When I input M, it shows me x1 and x2 as the columns with 1000 rows. I presume this is the matrix. The issue is when I find the transpose
A<- t(M)
A
tail(A)
It is like x2 disappears, and when I try to multiply A*M, I get the error that these are non comformable arrays.
I have tried this
M <- rbind(x1,x2)
M
tail(M)
Still, it is like x2 does not exist. What am I missing here?
Upvotes: 0
Views: 19
Reputation: 8811
dim()
allows to see the dimensions, where the first number is the number of rows and the second the numbers of columns, see that in M
we have 2 columns, x1
and x2
, since you used cbind()
> dim(M)
[1] 1000 2
> dim(A)
[1] 2 1000
After transposin M
to A
see that you have 2 rows, so x2
still there, but as the second row.
Upvotes: 0