[R] How to define variables as categorical using Gower with Daisy

Peter Ehlers ehlers at ucalgary.ca
Sun Feb 24 21:36:51 CET 2013


On 2013-02-24 07:57, Joanna Papakonstantinou wrote:
>> I am using the iris dataset that contains mixed variables (some columns are numeric and some categorical).
>>
>>> iris
>>      Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
>> 1            5.1         3.5          1.4         0.2     setosa
>> 2            4.9         3.0          1.4         0.2     setosa
>> 3            4.7         3.2          1.3         0.2     setosa
>> 4            4.6         3.1          1.5         0.2     setosa
>> .
>> .
>> .
>
>> I am trying to use the Gower metric so that I may specify that some columns contain categorical data.
>>> iris.clust<-daisy(iris, metric = "gower", stand = FALSE, type = list(factor="Species"))
> But it is saying that the types= I, I, I, I, N
> so obviously it is not reading the variable types correctly.

I don't know why you say that. Look at ?dissimilarity.object to see
what 'I' and 'N' mean.

If you read the help page for ?daisy carefully, you'll see that your
command is equivalent to

   iris.clust(iris)

i.e. you need not specify the metric etc.
BTW, your specification of 'type' indicates that you may have
looked at the help page a bit too hastily.

>
> Could someone please tell me how to specify the variable types correctly?
>
> Thank you.
> Joanna

Peter Ehlers



More information about the R-help mailing list