On 02/01/2010 07:52 PM, ogbos okike wrote:
Hello.
I am working with a set of variables which are in columns. Three of them
are of the same length while one has a different length. Typing
'>data<-matrix(c(ca$value, mo$value,b2$value, y1), ncol = 3)'
appears to read any three columns out of the four, though I can say exactly
which of these three columns are read.
However, typing '> data<-matrix(c(ca$value, mo$value,b2$value, y1), ncol =
4)' gives the warning message below:
'Warning message:
In matrix(c(ca$value, mo$value, b2$value, y1), ncol = 4) :
data length [26637] is not a sub-multiple or multiple of the number of
rows [6660]'
Since y1 is the variable that has a different length, I dropped and used
ncol = 3 and there was no error message. In order to be convinced that the
error message is due to the difference in length of y1, I included y1 and
dropped b2$value. There was no error message still, confusing me as to where
the error arises when I tried to use ncol = 4.
This implies that the matrix will accept any three column variables no
matter the length, but once it is 4 variables in which case I think I should
change ncol = 3 to ncol = 4 to reflect the number of columns. And I also
intend to increase the number of these columns to about 10. Should I not be
using ncol = n where n stands for the number of the columns I have in my
matrix?
Hi Ogbos,
The warning means that you will get three "recycled" values from
ca$value in the matrix that is generated. This happens whenever the
total length of the data is not an even multiple of the number of rows.
As I have never been able to resist these "number problems", I tried to
work out how the lengths of the first three vectors would have to be
distributed to be evenly divisible by three in both combinations. I
think that the lengths of ca$value, mo$value and b2$value must be
different for the swap of y1 and b2$value to also be divisible by three.
However, I couldn't get a unique solution. Perhaps one of the more
mathematical minds can crack the problem.
Jim
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.