[R] New to R, trying to use agnes, but can't load my ditance matrix
Sarah Goslee
sarah.goslee at gmail.com
Mon Jun 27 15:48:27 CEST 2011
On Mon, Jun 27, 2011 at 3:43 AM, Karen R. Khar <karen.khar at gmail.com> wrote:
> Hi,
>
> I'm mighty new to R. I'm using it on Windows. I'm trying to cluster using a
> distance matrix I created from the data on my own and called it D10.dist. I
> loaded the cluster package. Then tried the following command...
>
>> agnes("E:D10.dist", diss = TRUE, metric = "euclidean", stand = FALSE,
>> method = "average", par.method, keep.diss = n < 1000, keep.data = !diss)
> And it responded...
>
> Error in agnes("E:D10.dist", diss = TRUE, metric = "euclidean", stand =
> FALSE, :
> x is not and cannot be converted to class dissimilarity
>
At a guess, you need to actually import D10.dist into R. It looks like
you're trying to give agnes() a string that contains the path to the
file, but agnes() just sees that as a string, and of course can't
figure out what to do with it.
> D10.dist has the following data...
>
> D1 0
> D2 0.608392 0
> D3 0.497451 0.537662 0
> D4 0.634548 0.393343 0.537426 0
> D5 0.558785 0.543399 0.632221 0.726633 0
> D6 0.659483 0.701778 0.741425 0.668624 0.655914 0
> D7 0.603012 0.659173 0.571776 0.687599 0.383712 0.683948 0
> D8 0.611919 0.665357 0.526453 0.715093 0.457496 0.698213 0.317039 0
> D9 0.41501 0.652117 0.552011 0.68969 0.485988 0.702738 0.42819 0.442598 0
> D10 0.376512 0.600607 0.517857 0.673515 0.530421 0.667736 0.537025 0.48062
> 0.240559 0
If you can convince whatever software you used to write out a full
symmetric matrix instead of a lower-triangular matrix, you can easily
use read.table() to import it.
> I would appreciate any suggestions. Please assume I know virtually nothing
> about R.
Then Karen, my first suggestion is that you read one of the many
excellent intro to R guides available online.
Sarah
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list