Re: [R] error message from apply()

2008-02-06 Thread jim holtman
; operation ? > > > -Original Message- > From: jim holtman [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 06, 2008 11:33 > To: Ng Stanley > Cc: r-help > Subject: Re: [R] error message from apply() > > You matrix only has 3 rows, so when you do 'appl

Re: [R] error message from apply()

2008-02-05 Thread Stanley Ng
Subject: Re: [R] error message from apply() You matrix only has 3 rows, so when you do 'apply(data2_1,2,...)' you are extracting columns which only have a length of 3 while thr has a length of 10 > str(data2_1) num [1:3, 1:10] 0.958 0.271 -0.950 -0.130 -0.754 ... > str(thr) n

Re: [R] error message from apply()

2008-02-05 Thread jim holtman
You matrix only has 3 rows, so when you do 'apply(data2_1,2,...)' you are extracting columns which only have a length of 3 while thr has a length of 10 > str(data2_1) num [1:3, 1:10] 0.958 0.271 -0.950 -0.130 -0.754 ... > str(thr) num [1:10] 1.060 0.528 0.104 0.925 -0.256 ... > That is wh

Re: [R] error message from apply()

2008-02-05 Thread Ng Stanley
Replacing colMeans by mean removed the warning messages. Thanks However, when I precompute thr, and pass it to function(x), the error returns. Using the shorter data2_1, doesn't give any warnings. What is happening ? data2_1 <- matrix(c(0.9584190, 0.2710325, -0.9495618, -0.1301772, -0.7539687, 0.

Re: [R] error message from apply()

2008-02-05 Thread jim holtman
The error message was coming from the call to colMeans where 'x' was not a matrix; it was a vector that resulted from the 'apply' call. Did you intend to use 'mean' instead like this example: > data2_1 <- matrix(c(0.9584190, 0.2710325, -0.9495618, -0.1301772, -0.7539687, + 0.5344464, -0.8205933, 0

[R] error message from apply()

2008-02-05 Thread Ng Stanley
Hi, I keep getting the error message. Please help. Error in colMeans(x, na.rm = TRUE) : 'x' must be an array of at least two dimensions The codes are: data2_1 <- matrix(c(0.9584190, 0.2710325, -0.9495618, -0.1301772, -0.7539687, 0.5344464, -0.8205933, 0.1581723, -0.5351588, 0.04448065, 0.9936