Re: [R] distance function (analogue)

2007-07-17 Thread Gavin Simpson
On Tue, 2007-07-17 at 14:32 +0200, Birgit Lemcke wrote:
> Hello R-Users,
> 
> its again me with a question.
> Im using R 2.5.0 on Mac Power Book running Mac OS X 10.4.10

And again, you should send this to the maintainer (that'd be me), *not*
R-help! Unless you are asking help on a widely used package, it is
unlikely that anyone on R-Help can help you. And I'm not being modest
when I say that analogue is unlikely to fit that description.

> 
> I try to calculate distances betweeen two data tables looking like this
> 
>  V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18  
> V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
> 11  0  0  0  1  1  0  1  0   0   0   1   0   0   0   0   0   1
> 0   0   1   0   0   0   0   1   1   0   1   1   0   0   0   0   0   0
> 21  1  0  0  1  1  0  0  1   0   1   1   0   0   0   0   0   1
> 0   0   1   0   0   0   0   1   1   0   0   1   0   0   1   1   0   0
> 31  1  0  0  1  1  1  1  0   0   1   0   0   0   0   0   0   1
> 0   0   1   1   0   0   0   0   1   0   1   0   0   1   0   0   0   0
> 40  1  0  0  1  1  0  1  0   0   0   1   0   0   0   0   0   1
> 0   0   1   0   0   1   0   0   1   0   0   1   0   0   1   0   0   0
> 50  1  0  0  1  1  0  0  1   0   0   1   1   0   0   0   0   1
> 0   0   1   0   0   0   0   1   0   0   0   1   0   0   0   0   0   0
> 61  1  0  0  1  1  0  1  1   0   1   0   0   0   0   0   1   1
> 0   0   1   0   0   0   0   0   1   0   0   1   0   1   1   0   0   0

I need to know what R thinks the objects look like, not how you think
they look.

> As i know I did the same 2 weeks ago and it worked properly.
> 
> Here are my codes:
> 
> Table1<-read.table("Alle_DatenFemBeschr4a.csv", sep = ";")
> 
> Table0<-read.table("Alle_DatenMalBeschr4a.csv", sep = ";")
> 
> Dist.Gower<- distance(Table1 ,Table0 ,method ="mixed", weights = c 
> (0.333, 0.333, 0.333, 0.500, 0.500, 0.500,  
> 0.500, 0.500, 0.500, 0.250, 0.250, 0.250,  
> 0.250, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,  
> 0.1428571, 0.1428571, 0.333, 0.333, 0.333, 0.200,  
> 0.200, 0.200, 0.200, 0.200, 0.111, 0.111,  
> 0.111, 0.111, 0.111, 0.111, 0.111, 0.111,  
> 0.111, 0.200, 0.200, 0.200, 0.200, 0.200,  
> 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,  
> 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,  
> 0.1428571, 0.1428571, 0.200, 0.200, 0.200, 0.200,  
> 0.200, 0.500, 0.500, 0.500, 0.500, 0.500,  
> 0.500, 0.500, 0.500, 0.500, 0.500, 0.500,  
> 0.500, 0.500, 0.500, 0.500, 0.500, 0.500,  
> 0.500, 0.500, 0.500, 0.500, 0.500, 0.500,  
> 0.500))
> 
> This produces the following massage:
> 
> Fehler in distance(Table1, Table0, method = "mixed", weights = c 
> (0.333,  :
>   Different columns (species) are coded as factors in 'x' and 'y'

This means that Table1 has columns coded as factors that are not coded
factors in Table0 or vice versa.

Do 

> str(Table1)
> str(Table0)

and compare the output.

Alternatively, send me the two csv files you are reading in and I'll try
to track down the problem for you.

G

Ps: It would be easier to read if you did

my.weights <- c (0.333, 0.333, 0.333, 0.500, 0.500,
0.500, 0.500, 0.500, 0.500, 0.250, 0.250,
0.250, 0.250, 0.1428571, 0.1428571, 0.1428571, 0.1428571,
0.1428571, 0.1428571, 0.1428571, 0.333, 0.333, 0.333,
0.200, 0.200, 0.200, 0.200, 0.200, 0.111,
0.111, 0.111, 0.111, 0.111, 0.111, 0.111,
0.111, 0.111, 0.200, 0.200, 0.200, 0.200,
0.200, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,
0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,
0.1428571, 0.1428571, 0.1428571, 0.200, 0.200, 0.200,
0.200, 0.200, 0.500, 0.500, 0.500, 0.500,
0.500, 0.500, 0.500, 0.500, 0.500, 0.500,
0.500, 0.500, 0.500, 0.500, 0.500, 0.500,
0.500, 0.500, 0.500, 0.500, 0.500, 0.500,
0.500, 0.500)

Dist.Gower <- distance(Table1, Table0, method ="mixed", weights =
my.weights)

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch mailing list
htt

[R] distance function (analogue)

2007-07-17 Thread Birgit Lemcke
Hello R-Users,

its again me with a question.
I´m using R 2.5.0 on Mac Power Book running Mac OS X 10.4.10

I try to calculate distances betweeen two data tables looking like this

 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18  
V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
11  0  0  0  1  1  0  1  0   0   0   1   0   0   0   0   0   1
0   0   1   0   0   0   0   1   1   0   1   1   0   0   0   0   0   0
21  1  0  0  1  1  0  0  1   0   1   1   0   0   0   0   0   1
0   0   1   0   0   0   0   1   1   0   0   1   0   0   1   1   0   0
31  1  0  0  1  1  1  1  0   0   1   0   0   0   0   0   0   1
0   0   1   1   0   0   0   0   1   0   1   0   0   1   0   0   0   0
40  1  0  0  1  1  0  1  0   0   0   1   0   0   0   0   0   1
0   0   1   0   0   1   0   0   1   0   0   1   0   0   1   0   0   0
50  1  0  0  1  1  0  0  1   0   0   1   1   0   0   0   0   1
0   0   1   0   0   0   0   1   0   0   0   1   0   0   0   0   0   0
61  1  0  0  1  1  0  1  1   0   1   0   0   0   0   0   1   1
0   0   1   0   0   0   0   0   1   0   0   1   0   1   1   0   0   0

As i know I did the same 2 weeks ago and it worked properly.

Here are my codes:

Table1<-read.table("Alle_DatenFemBeschr4a.csv", sep = ";")

Table0<-read.table("Alle_DatenMalBeschr4a.csv", sep = ";")

Dist.Gower<- distance(Table1 ,Table0 ,method ="mixed", weights = c 
(0.333, 0.333, 0.333, 0.500, 0.500, 0.500,  
0.500, 0.500, 0.500, 0.250, 0.250, 0.250,  
0.250, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,  
0.1428571, 0.1428571, 0.333, 0.333, 0.333, 0.200,  
0.200, 0.200, 0.200, 0.200, 0.111, 0.111,  
0.111, 0.111, 0.111, 0.111, 0.111, 0.111,  
0.111, 0.200, 0.200, 0.200, 0.200, 0.200,  
0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,  
0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571,  
0.1428571, 0.1428571, 0.200, 0.200, 0.200, 0.200,  
0.200, 0.500, 0.500, 0.500, 0.500, 0.500,  
0.500, 0.500, 0.500, 0.500, 0.500, 0.500,  
0.500, 0.500, 0.500, 0.500, 0.500, 0.500,  
0.500, 0.500, 0.500, 0.500, 0.500, 0.500,  
0.500))

This produces the following massage:

Fehler in distance(Table1, Table0, method = "mixed", weights = c 
(0.333,  :
Different columns (species) are coded as factors in 'x' and 'y'

I thought that the data format in the tables were not congruent in  
the same columns but I checked this and it is not the case.

I also tried to convert the data into a matrix (as.matrix) or a  
dataframe (as.data.frame) but the result was the same. Perhaps it is  
only a small syntax error but I am R beginner.

I hope somebody wil help me and thank you all in advance.

Kind regards

Birgit

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.