[R] Problem with dist (bug?)

Corrado ct529 at york.ac.uk
Fri Oct 2 15:12:08 CEST 2009


Dear list,

here is the code that generates the problem:

library(proxy)
scot<-read.csv("scot.csv",header=TRUE)
scot24_climate<-scot24[,1105:1109]

# Scotland
dist_scot24_climate<-
dist(scot24_climate,method="correlation",diag=TRUE,upper=TRUE)

max(dist_scot24_climate)  

is 1.9. I do not think it should be, because the value is usually the cos() of 
the angle between the 2 vectors. If you use method="cosine" you have  1.8, 
which I think it should not be.

Is there a problem with the way I use it, or is there a bug?

I have been able to reduce the scot.csv to under 200MB, but I thought of not 
posting it to the list ....

> We need to see the data and the script that produced the error.
>
> On Fri, Oct 2, 2009 at 5:06 AM, Corrado <ct529 at york.ac.uk> wrote:
> > Dear list,
> >
> > using package "proxy".
> >


> > In one situation, the dissimilarity between two vectors based on
> > method=correlation returns a value of 1.9. That should not happen, should
> > it?
> >
> > The correlation is normally the cos() of the angle between the two
> > vectors ....
> >
> > Any clue?
> >
> > Package dist 0.4-3 on R 2.9.2 on Kubuntu 904 64 bit.
> >
> > Regards
> > --
> > Corrado Topi
> >
> > Global Climate Change & Biodiversity Indicators
> > Area 18,Department of Biology
> > University of York, York, YO10 5YW, UK
> > Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk
> >
> > ______________________________________________
> > 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.



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk




More information about the R-help mailing list