Thank you all.
It's not easy to find the right keywords to search for
some things. My problem was related to the cclust
package, and I still think that the cclust code will
not work for unidimensional data. I will fix the
my copy of the cclust code according to your suggestion.
Moacir Pedroso Jr
This is expected behavior:
?'['
Usage:
x[i]
x[i, j, ... , drop = TRUE]
drop: For matrices and arrays. If 'TRUE' the result is coerced to
the lowest possible dimension (see the examples). This only
works for extracting elements, not for the replacement. See
You need drop=FALSE: see ?'['
> x<- matrix(rnorm(100), ncol=1)
> str(x)
num [1:100, 1] -0.626 0.184 -0.836 1.595 0.330 ...
> str(x[20:30,])
num [1:11] 0.5939 0.9190 0.7821 0.0746 -1.9894 ...
> str(x[20:30,,drop=FALSE])
num [1:11, 1] 0.5939 0.9190 0.7821 0.0746 -1.9894 ...
>
On Tu
On 22/10/2008, at 2:24 AM, Pedroso MOACIR wrote:
Hi all,
Why subscripting a one column matrix drops one dimension?
x<- matrix(rnorm(100), ncol=1)
str(x)
num [1:100, 1] -0.413 -0.845 -1.625 -1.393 0.507 ...
str(x[20:30,])
num [1:11] -0.315 -0.693 -0.771 0.448 0.204 ...
str(x[20:
Hi all,
Well, I just sent a help msg to the list with this subject,
but I think I figured out a way to solve my problem
(although I still have no clue if the behavior I described
is correct).
What I did was to replace occurrences of (for example)
cov(x[sub, ])
with
Two solutions:
1) Follow the Posting Guide
2) Use the function help.request() [new to R-2.8.0] to figure how
what steps to take.
Each method leads to the solution here:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f
Hi all,
Why subscripting a one column matrix drops one dimension?
> x<- matrix(rnorm(100), ncol=1)
> str(x)
num [1:100, 1] -0.413 -0.845 -1.625 -1.393 0.507 ...
> str(x[20:30,])
num [1:11] -0.315 -0.693 -0.771 0.448 0.204 ...
> str(x[20:30])
num [1:11] -0.315 -0.693 -0.771 0.448 0.204 ..
7 matches
Mail list logo