将马赛克图表示为树状图
我想以树的形式可视化马赛克图。例如
mosaicplot(~ Sex + Age + Survived, data = Titanic, color = TRUE)
现在我想要的是以树的形式表示它,其中第一个节点 例如,性别是第二个节点,年龄是终端节点,幸存者的数量是终端节点。可能应该类似于 http://addictedtor.free.fr/graphiques/RGraphGallery .php?graph=84 其中代替 p 给出计数数。 R中有一个函数可以做到这一点还是我应该自己写一下 在 party:::plot.BinaryTree 函数中
I want to visualize a mosaic plot in form of a tree. For example
mosaicplot(~ Sex + Age + Survived, data = Titanic, color = TRUE)
Now what I want is to represent this in a tree form where the first node
for example be sex the second node be age and at the terminal node be number of people survived. May be it should something like http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=84 where instead of p giving the number of counts.
Is there an function in R to do this or should I write it on my own by taking at a look
at the party:::plot.BinaryTree
function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是我如何通过可爱的 igraph 包获得我想要的东西。该代码是一个丑陋的黑客。很高兴收到您的建议
这是我生成的情节。您可以根据需要修改顶点/边颜色/大小
Here is how I managed to get what I wanted with the lovely igraph package. The code is an ugly hack. It will be great to have you suggestions
Here is the plot I generate. You can modify the vertex/edge colors/size as you want
这非常接近,对我来说看起来容易多了。我将其发布在这里,以防它可能有用。首先,我使用 Expand.dft https://stat.ethz.ch/pipermail/r-help/2009-January/185561.html 然后我只使用plotrix包中的plot.dendrite函数。
This is pretty close and looks a lot easier to me.. I post it here in case it may be of use. First I convert the ftable to a more traditional long data frame using expand.dft https://stat.ethz.ch/pipermail/r-help/2009-January/185561.html Then I just use the plot.dendrite function from the plotrix package.