Skip to content

R help with princomp and pam clustering

3 messages · Tyler82, Joris Meys

#
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 :(
Using princomp I menaged to extract the $scores and plot the graph. Wouldn't
using princomp on the B dataset generate different PC? 
Thank you all!
Bye!!

Claudio
#
On Thu, Nov 26, 2009 at 1:04 AM, Tyler82 <procaccianti.claudio at gmail.com> wrote:
Prin <- princomp(A)
predict(Prin,B)

in the assumption that the variable names in both dataframes are equal.
Indeed, it would.
#
Hi JorisMeys and thanks!
JorisMeys wrote:
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!!