I'm doing hierarchical clustering, and want to export my dendrogram to a tree-viewing/editing software. I can do this by converting the data to Newick format (hc2Newick in ctc package), but I can't get branch lengths to show in the resulting phylogram. I figured it might help to convert my hclust object into a phylo object (as.phylo in ape package), but the following lines give me this "Error in UseMethod("as.phylo") : no applicable method for 'as.phylo' applied to an object of class "character":
data = read.table("C:/path/data.txt")
d <- dist(data, method = "euclidean")
fit <- as.phylo(hclust(d, method="ward")
Would anyone have an idea about how to make this work?