I built a dendrogram in R with code:
data(iris) aver<-sapply(iris[,-5],function(x) by(x,iris$Species,mean)) matrix<-dist(aver) clust<-hclust((matrix),"ave") clust$labels<-row.names(aver) plot(as.dendrogram(clust))
I wanted to save the dendrogram as an svg file using the code:
install.packages("Cairo") library(Cairo) svg("plot.svg") plot(as.dendrogram(clust)) dev.off()
Here's the problem:
When I imported "plot.svg" into Inkscape (ver: 0.48.4) and selected any label (for example, "setosa"), it was not recognized as text, but rather as some "user-defined" object. In particular, when I selected any letter in the label and checked it using the XML editor (ctrl + shift + X) in Inkscape, I got this information:
**id**: use117 **x**: 142.527344 **xlink:href**: #glyph0-8 **y**: 442.589844
On the other hand, when I manually wrote "setosa" using the "create and edit text objects" tool and checked in the XML editor, it returned:
**id**: text4274 **sodipodi:linespacing**: 125% **style**: font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Palatino Linotype;-inkscape-font-specification:Palatino Linotype **transform**: scale(0.8,0.8) **x**: 176.02016 **xml:space**: preserve **y**: 596.96674
Inkscape probably did not recognize the labels as text according to the id attribute of the XML Editor. Therefore, I cannot change the font, size, or use other functions related to text objects in Inkscape.
Here is the svg file I made with the previous code and imported into Inkscape
I checked the previous steps using other versions of Inkscape as well as R, but that would be the same.
Here is the question:
Do you have any idea how I can collect tags as a text attribute instead of "user defined" (or that it is an object ...) when importing svg files from R to Inkscape?
UPDATE
@baptiste is connected to the SO stream , where @Oscar PerpiΓ±Γ‘n suggested three packages (gridSVG, SVGAnnotation and RSVGTipsDevice) that control the SVG. Unfortunately, none of the packages offered could solve the problem with the text problem. So far I have found the SO stream , where @Mo Sander suggested the RSvgDevice package, since it can save a text object, not glyphs. Having started the installation procedure of RSvgDevice, I found that it is RSvgDevice only available for 32-bit installations, and R <2.15.0. Otherwise, R returned a warning message:
Warning message: package 'RSvgDevice' is not available (for R version 3.0.1)
Besides the requirements for older versions of R, currently only RSvgDevice can save a text object in SVG.