Re: [R] R help with princomp and pam clustering

From: Joris Meys <jorismeys_at_gmail.com>
Date: Thu, 03 Dec 2009 13:26:37 +0100

Hi Tyler,

sorry, I missed your response. Don't know if it's solved already, but some remarks.
the predict uses a princomp object, so your second command should work.

I guess the problem is either the data format of B (should contain exactly the same amount of columns, with the same names), or the cor specification you use.

Try :
Cor <- ncol(pamX$data)!=2
Prin <- princomp(matrix,cor=Cor)
predict(Prin,B)

It works perfectly well on every test I run.

Cheers
Joris

On Fri, Nov 27, 2009 at 10:14 AM, Tyler82 <procaccianti.claudio_at_gmail.com> wrote:
>
> Hi JorisMeys and thanks!
>
>
> JorisMeys wrote:
>>
>> On Thu, Nov 26, 2009 at 1:04 AM, Tyler82 <procaccianti.claudio_at_gmail.com>
>> wrote:
>>>
>>> Hi all!
>>> I am working with R package cluster and I have a little problem:
>>> let's say I have two datasets...first one ("A") is divided into 4
>>> clusters
>>> by means of Pam algorythm.
>>> Let's say I want to project the second database ("B") onto the Comp.1 X
>>> Comp.2 graph, and see where its elements are placed.
>>> The two datasets are made of different dim (54x19 and 28x19). I tried to
>>> extract the $loadings of the A clustering but I can't seem to figure out
>>> how
>>> to use them with B :(
>>
>> Prin <- princomp(A)
>> predict(Prin,B)
>>
>> in the assumption that the variable names in both dataframes are equal.
>
> A and B are equal in column names (variables) but different in rownames
> (observations), but still it doesn't work.
> If I use
> A<-princomp(matrix, cor=ncol(pamX$data)!=2)$loadings
> and then
> predict(A,B)
> then the answer is that there is no valid method
> (My R version is in Italian...the original message is -Errore in
> UseMethod("predict") : nessun metodo applicabile per "predict"- )
> If I use
> A<-princomp(matrix, cor=ncol(pamX$data)!=2)
> then it says the index is out of limit
>
> Thank you again!!
>
> --
> View this message in context: http://old.nabble.com/R-help-with-princomp-and-pam-clustering-tp26522485p26539667.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.
>



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. Received on Thu 03 Dec 2009 - 12:29:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Dec 2009 - 14:00:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive