[R] subscripting a one column matrix drops dimension
moacir at supagro.inra.fr
moacir at supagro.inra.fr
Tue Oct 21 23:10:57 CEST 2008
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.
Embrapa - Empresa Brasileira de Pesquisa Agropecuária
(on leave at INRA - Instutute National de la Recherche Agronomique)
Quoting Jeff Ryan <jeff.a.ryan at gmail.com>:
>
> 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 at 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 at 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.
>
More information about the R-help
mailing list