[R] exploring dist()

Sarah Goslee sarah.goslee at gmail.com
Fri Mar 18 14:56:05 CET 2011


It isn't quite clear what you're doing. Do you
already have distances calculated elsewhere
and imported into R?

If so, then if you import the *full symmetric* distance
matrix, you can convert it into a distance object using
as.dist().

If you only have the lower triangle, you can use eg
full() from ecodist to create the full symmetric matrix,
then use as.dist.

What your sample code does is try to create a Euclidean
distance matrix from your data, treating it as 4087 samples
with two attributes measured for each.

There aren't values missing; you are getting a lower
triangular distance matrix for 4087 samples.

You need to clarify what you are trying to do.

Sarah

On Fri, Mar 18, 2011 at 9:21 AM, bra86 <anastasia.krikovtseva at tugraz.at> wrote:
> Hello, everybody,
>
> I hope somebody could help me with a dist() function.
> I have a data frame of size 2*4087 (col*row), where col corresponds to the
> treatment and rows are
> species, values are Hellinger distances, I should reconstruct a distance
> matrix
> with a dist() function. I know that "euclidean" method should be used.
>
> When I type:
> dist(dframe,"euclidean")
> it gives me a truncated table, where values are missing.
>
> I suppose that I have to define something for the values,
> but I have no idea what exactly, because I am not familiar with r at all.
>
> I would be very appreciated for every kind of suggestions or tips.
>
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list