[R] Simple Question About Exporting Back to Excel

David L Carlson dcarlson at tamu.edu
Thu Sep 27 02:31:40 CEST 2012


Check the return values for hclust using ?hclust (particularly the
value order):

> set.seed(42)
> x <- matrix(rnorm(100), nrow=25)
> outp <- hclust(dist(x))
> plot(outp)
> outp$order
[1]  9  6 16  1  7 24 25  3 14 11 12 20 18 19 23  4 10  5 17 13 22  2
15  8 21

You could use this to reorder the data set before sending it back to
Excel:
xnew <- x[outp$order,]

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of RCar
> Sent: Wednesday, September 26, 2012 4:12 PM
> To: r-help at r-project.org
> Subject: [R] Simple Question About Exporting Back to Excel
>
> All,
> Relatively new R user so this is probably an easy question to answer.
> I am able to generate a cluster for my dataset using hclust() then
> ploting the data with plot().
> This results in an image with a dendrogram with my sample names along
> the bottom.  Great! However, I now need a way to get that sample order
> from the image into excel. i.e. sample 7 was on the far left, sample 19
was
> in position 2, sample 93 was in position 3, etc. As of now the only way
for
> me to do this is to manually type the samples from the image into a
worksheet.
> Very time consuming as I've got a couple hundred samples and several
> different dendrograms!
> Any thoughts?
>
> Thanks so much!
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Simple-
> Question-About-Exporting-Back-to-Excel-tp4644296.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.




More information about the R-help mailing list