[R] type in daisy

Martin Maechler maechler at stat.math.ethz.ch
Tue Mar 21 10:09:25 CET 2006

>>>>> "Jeanne" == Jeanne Vallet <Jeanne.Vallet at inh.fr>
>>>>>     on Mon, 20 Mar 2006 18:33:08 +0100 writes:

    Jeanne> Hi, I'm a PhD student and I want to use the function
    Jeanne> 'daisy' from the package 'cluster' to compute
    Jeanne> dissimilarities.  My variables are of mixed types so
    Jeanne> I use the argument 'stand' in daisy to define the
    Jeanne> type of my variables. 
you mean 'type' not 'stand';  yes, that's good
    Jeanne> I have the following error message : 

    Jeanne> Warning message: 
no, it's *NOT* an error message.  
A warning is a warning is a warning is a warning is a warning!
Sorry to stress this to the extreme; but it happens too often
that people confuse warnings with errors.

    Jeanne> binary variable(s) 13, 16, 17, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
    Jeanne> 32, 33, 34, 35, 36, 37, 38, 39 treated as interval scaled in:
    Jeanne> daisy(basetraits, stand = FALSE, type = list(numeric = c(1, 7),  

    Jeanne> I don't understand why R
    Jeanne> doesn't accept that I declare these binary variables
    Jeanne> in symm or assym (depending on the variable).
well below you only declare 12 & 14 in 'symm' and
15 & 40 in 'asymm'.  Hence all the above are treated as interval scaled.

daisy() gives a warning {which I had added a while ago}, because
Kaufmann & Rousseeuw in their book make a point -- on which I
agree -- that people should carefully consider how
(dis)similarities between binary variables should be defined.

But after all it's just a warning, not an error!

    Jeanne> Thanking you in anticipation, Jeanne Vallet
    Jeanne> PS : To help you to understand my question, my script is : 

    Jeanne> aa<-file.choose()
    Jeanne> basetraits<-read.csv2(aa, header = TRUE,row.names=1)
    Jeanne> #variables declaration
The following is completely useless  (and horrible reading (with
"=" and no spaces), and unnecessary):
You don't change basetraits at all with these statements

    Jeanne> attach(basetraits)
    Jeanne> pdias=as.numeric(pdias)
    Jeanne> longindex=as.numeric(longindex)
    Jeanne> light=as.numeric(light)
    Jeanne> humid=as.numeric(humid)
    Jeanne> basic=as.numeric(basic)
    Jeanne> azot=as.numeric(azot)
    Jeanne> durflow=as.numeric(durflow)
    Jeanne> height=as.ordered(height)
    Jeanne> spread=as.ordered(spread)
    Jeanne> begflow=as.ordered(begflow)
    Jeanne> mycor=as.ordered(mycor)
    Jeanne> piq=as.factor(piq)
    Jeanne> lign=as.factor(lign)
    Jeanne> grain=as.factor(grain)
    Jeanne> ros=as.factor(ros)
    Jeanne> semiros=as.factor(semiros)
    Jeanne> leafy=as.factor(leafy)
    Jeanne> autopoll=as.factor(autopoll)
    Jeanne> geito=as.factor(geito)
    Jeanne> insect=as.factor(insect)
    Jeanne> wind=as.factor(wind)
    Jeanne> suman=as.factor(suman)
    Jeanne> winan=as.factor(winan)
    Jeanne> monocarp=as.factor(monocarp)
    Jeanne> polycarp=as.factor(polycarp)
    Jeanne> phan=as.factor(phan)
    Jeanne> cham=as.factor(cham)
    Jeanne> hemi=as.factor(hemi)
    Jeanne> geo=as.factor(geo)
    Jeanne> thero=as.factor(thero)
    Jeanne> seasaes=as.factor(seasaes)
    Jeanne> seashiv=as.factor(seashiv)
    Jeanne> seasver=as.factor(seasver)
    Jeanne> everalw=as.factor(everalw)
    Jeanne> everparti=as.factor(everparti)
    Jeanne> endozoo=as.factor(endozoo)
    Jeanne> epizoo=as.factor(epizoo)
    Jeanne> aquat=as.factor(aquat)
    Jeanne> wind=as.factor(wind)
    Jeanne> detach(basetraits)
    Jeanne> #dissimilarities calculation
    Jeanne> library(cluster)
    Jeanne> daisybase<-daisy(basetraits,stand=FALSE,type=list(numeric=c(1,7),ordrati
    Jeanne> o=c(8,11),symm=c(12,14),asymm=c(15,40)))

More information about the R-help mailing list