这在以前从来就不是问题,但是最近当我尝试生成树形图(使用R treemap package),其中矩形按值I排序时,我无法这样做。而是通过索引名称按字母顺序排列矩形。我是否在任何时候误解了最近的文档,或者这是一个不可重现的问题(与我的软件包安装有关)?
下面的可重复示例。生成的树形图按字母顺序排列,当我希望按照“vals'大小
library(treemap)
names <- as.character(c("a", "c", "b", "d"))
vals <- c(10, 20, 65, 5)
tree_ex <- as.data.frame(cbind(names, vals), )
tree_ex$vals <- as.numeric(as.character(tree_ex$vals))
treemap(tree_ex, index='names', vSize = "vals",
algorithm = "pivotSize",
sortID = "vals")
答案 0 :(得分:1)
包裹坏了。下面的可重复示例。另请参阅我刚刚在github上为treemap包提交的Issue #30
重现破坏行为的代码:
# create data set
set.seed(1234)
df <- data.frame(A=LETTERS[1:12],size=seq(12,1),sort=sample(12))
# install the last version with sortID respected and plot treemap
devtools::install_github("treemap", user="mtennekes", subdir="pkg",ref="5ca7c0b562e4a60bab111752210d6aba8995f55a")
library(treemap)
treemap(df,index="A",vSize="size",algorithm="pivotSize",sortID="sort")
# install the version which breaks sortID and plot treemap
devtools::install_github("treemap", user="mtennekes", subdir="pkg",ref="d8817db2805058f6a36db9f882790681961bc052")
library(treemap)
treemap(df,index="A",vSize="size",algorithm="pivotSize",sortID="sort")
更新 2016-03-23
包已修复Commit 0224354