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
          'drop' for further details. 

try cov(x[sub, drop=FALSE])

HTH
Jeff



Pedroso MOACIR wrote:
> 
> 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
> 
>                 cov(matrix(x[sub, ], ncol=ncol(x))
> 
> It works.
> 
> I updated my source version of the cclust package. It
> may be of interest to somebody else, but I don't know
> how to submit to the package mantainer.
> 
> Thank you.
> 
> Moacir Pedroso Jr.
> Embrapa - Empresa Brasileira de Pesquisa Agropecuária
> (on leave at INRA - Instutute National de la Recherche Agronomique)
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/subscripting-a-one-column-matrix-drops-dimension-tp20098143p20098917.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to