Displaying 20 results from an estimated 80000 matches similar to: "Distance matrix from a binary data frame"
2008 Jan 10
2
Error on distance matrix
Hi,
I am trying to calculate a distance matrix on a binary data frame using
dist.binary() {ade4}. This is the code I run and the error I get:
> sjlc.dist <- dist.binary(as.data.frame(data), method=2) #D = (a+d) /
(a+b+c+d)
Error in if (any(df < 0)) stop("non negative value expected in df") :
missing value where TRUE/FALSE needed
I don't know if the problem are the
2017 Dec 31
1
Perform mantel test on subset of distance matrix
I'm trying to perform a mantel test that ignores specific pairs in my
distance matrices. The reasoning is that some geographic distances
below a certain threshold suffer from spatial autocorrelation, or
perhaps ecological relationships become less relevant that stochastic
processes above a certain threshold.
The problem is that I can't find a way to do it. If I replace values
in either or
2009 Apr 15
2
How to Reshuffle a distance object
I would like to randomly shuffle a distance object, such as the one
created by ade4{dist.binary} below. My first attempt, using
sample(jc.dist) creates a shuffled vector, losing the lower triangular
structure of the distance object. How can I Ishuffle the lower
triangular part of a distance matrix without losing the structure?
Thanks. --Dale
x1 <- c(rep(0,4),1)
x2 <- c(rep(0,2),rep(1,3))
2008 Jun 10
2
Slow function
Hi,
I have the following function that I want to apply to a list of 14
matrices (1536 x 170) of binary data:
DRes <- function(x, nr = 10000, metric = "mixed", ...) {
require(analogue)
require(ade4)
m <- c()
for (i in 1:nr) {
set.seed(i)
x1 <- x[, sample(dimnames(x)[[2]], length(x[1,])/2)]
x2 <- x[, !dimnames(x)[[2]] %in% dimnames(x1)[[2]]]
d1 <-
2007 Oct 16
2
Canberra distance
Hi,
I misunderstand the definition of Canberra distance in R.
On Internet and in function description pages of dist() from stats and
Dist() from amap, Canberra distance between vectors x and y, d(x,y), is :
d(x,y) = sum(abs(x-y)/(x+y))
But in use, through simple examples, we find that the formula is :
d(x,y) = (NZ + 1)/NZ * sum(abs(x-y)/(x+y))
with NZ = nb of pairs of coordinates that are
2009 Nov 13
1
binary data
hi,
I am trying to calculate distance matrices for binary data frame. I am using dist.binary in 'ade4' package. This is the code i run and get error message as 'missing value where True/FalseĀ needed:
clss <- as.data.frame(cls)
dist.binary(clss, method = 1, diag = FALSE, upper = FALSE)
Also, if i convert the factors into numeric(i.e,1&2 in the place of 0&1 for present/absent
2009 Oct 15
1
changing a matrix from class data.frame to class dist
Dear,
I have a data frame object (FSTc) which is in fact a matrix of class
data.frame but created from a txt file using the command
FSTc<-read.table("FSTcmatrix.txt", header=T)
I would like to transform it in a distance matrix of class dist to use
it with the ade4 package.
I'm quite sure this is a simple operation but i just don't have the
commands.
Could anyone help?
2013 May 02
2
Calculating distance matrix for large dataset
Dear R users
I wondered if any of you ever tried to calculate distance matrix with very
large data set, and if anyone out there can confirm this error message I
got actually mean that my data is too large for this task.
negative length vectors are not allowed
My data size and code used
dim(mydata_nor)[1] 365000 144> d <- dist(mydata_nor, method = "euclidean")
Here my
2006 Aug 07
5
kmeans and incom,plete distance matrix concern
Hi there
I have been using R to perform kmeans on a dataset. The data is fed in using read.table and then a matrix (x) is created
i.e:
[
mat <- matrix(0, nlevels(DF$V1), nlevels(DF$V2),
dimnames = list(levels(DF$V1), levels(DF$V2)))
mat[cbind(DF$V1, DF$V2)] <- DF$V3
This matrix is then taken and a distance matrix (y) created using dist() before performing the kmeans clustering.
My query
2008 Apr 24
0
Name of objects in a list
Hi useRs,
I am trying to compare several distance matrices obtained from subsets
of variables from the same experiment. I put all the subsets in a list
and then calculated the distance matrices with lapply. In order to do a
mantel test between them I wrote a function the returns a list with the
output of single tests. I would like to include the name of the tests,
so I know what each element
2005 Oct 06
1
Compare two distance matrices
Hi all,
I am trying to compare two distance matrices with R. I would like to
create a XY plot of these matrices and do some linear regression on
it. But, I am a bit new to R, so i have a few questions (I searched in
the documentation with no success).
The first problem is loading a distance matrix into R. This matrix is
the output of a the Phylip program Protdist and lookes like this:
5
2013 Jul 18
1
binary distance measure of the "dist" function in the "stats" package
Dear all:
I want to ask question about "binary" distance measure. As far as I
know, there are many binary distance measures,eg, binary Jarcad distance,
binary euclidean distance, and binary Bray-Curtis distance,etc. It is even
more confusing because many have more than one name. So , I wan to know
what the definite name of the binary distance measure of the "dist"
function
2009 Jun 26
1
50993 point distance matrix, too big to as.matrix, looking for another way to calculate point-level summary
Hello, Im working on a 50933 point count bird abundance dataset. I've
succeeded in calculating a distance matrix for this entire set, but I don't
have sufficient memory to convert this to a matrix, as below...
abun.dist <- dist(abun.mat[1:50993,1:235)
test <- rowMeans(as.matrix(abun.dist))
Error in matrix(0, size, size) : too many elements specified
ive been able to run a hclust()
2006 Jan 18
0
r-help, how can i use my own distance matrix without usin g dist()
Use something like hclust(as.dist(mydist), ...) ought to work.
Andy
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of ucecgxu at ucl.ac.uk
Sent: Wednesday, January 18, 2006 4:47 PM
To: r-help at stat.math.ethz.ch
Subject: [R] r-help, how can i use my own distance matrix without using
dist()
Dear R-helpers,
i am a
2013 Apr 06
1
list of distance matrices
Dear UseRs,
i want to apply mantel test by comparing a list of 124 distance matrices with a reference distance matrix "q". The list of distance matrices was created by the following command..
u<-lapply(el, function(x) dist(x))
where "el" is a data frame of 75 columns and 124 rows. Therefore, the list of distances matrices, made out of it should have 75 elements each
2009 Jun 15
0
How to build phylogenetic tree by R program from distance any distance matrix
Hello R users,
Can any one please help me to find a way to build phylogenetic tree by R
program from any distance matrix.
Suppose I have a data like :
MATRIX
[1] '1' 0.0
[2] '2' 0.071 0.0
[3] '3' 0.036 0.286 0.0
[4] '4' 0.429 0.75 0.714 0.0
[5] '5' 0.679 0.179 0.214 0.536 0.0
[6] '6' 0.893 0.929 0.964 0.464 0.357 0.0
[7]
2002 Jan 25
1
Fw: Summary for Distance matrix by cosine?
Dear all,
below you find enclosed my message from January 9th and my program
(attention: beginner).
Thanks for both answers! a. However, as far as I know the cosine is not the
same as the Pearson correlation (only in special cases).
b. Reid Huntsinger's hint was very useful, however I had to transpose the
matrix first, for I want to calculate the distance of the _rows_.
Regards,
Petra
2006 Jan 18
1
r-help, how can i use my own distance matrix without using dist()
Dear R-helpers,
i am a beginner of R and i am using cluster package to do hierarchical
clustering
i am wondering if i can use my own distance matrix to do the hierarchical
clustering without using dist() function.
if i have my own distance matrix, how can i ask hclust() function to recongnize
it( as the output of dist() function).
thank you very much and i looking forward to hearing from you.
2011 Jul 24
0
setting distance matrix and clustering methods in heatmap.2
heatmap.2 defaults to dist for calculating the distance matrix and hclust for
clustering.
Does anyone now how I can set dist to use the euclidean method and hclust to
use the centroid method?
I provided a compilable sample code bellow.
I tried: distfun = dist(method = "euclidean"),
but that doesn't work. Any ideas?
library("gplots")
library("RColorBrewer")
test
2012 Jun 16
1
Efficient distance calculation on big matrix
Hi All,
I'm working on analyzing a large data set, lets asume that
dim(Data)=c(1000,8700). I want to calculate the canberra distance
between the columns of this matrix, and using a toy example ('test' is
a matrix filled with random numbers 0-1):
> system.time(d<-as.matrix(dist(t(test), method = "canberra", diag = FALSE, upper = FALSE, p = 2)))
user system