Can we subtract two arrays (or two vectors) that were written with different commands?
Example:
x<-array(1:4,c(4,1,1))
y<-cbind(c(1:4))
x-y
"Error> non-conformable objects"
Does this mean that both vectors have to use the same commands?
Can we subtract two arrays (or two vectors) that were written with different commands?
Example:
x<-array(1:4,c(4,1,1))
y<-cbind(c(1:4))
x-y
"Error> non-conformable objects"
Does this mean that both vectors have to use the same commands?
Your x
object has dimensions 4x1x1 and the object y only 4x1, you can not subtract objects with different dimensions.
If you put the dimensions 4x1 in x
it works:
x<-array(1:4,c(4,1))
y<-cbind(c(1:4))
x-y
[,1]
[1,] 0
[2,] 0
[3,] 0
[4,] 0
No; means only that x
and y
are objects of different dimensions. for example,
x<-array(1:4,dim=c(4))
y = 1:4
x-y
[1] 0 0 0 0