如何控制树形图包中的类别数?

时间:2014-07-16 14:14:55

标签: r treemap

在下面的示例中,treemap自动为“employees”生成8个类别。我怎么能改变它,即4类?我还可以设置类别的范围吗? 感谢

library(treemap)

data(business)

treemap(business,
        index=c("NACE1", "NACE2"),
        vSize="employees",
        vColor="employees",
        title.legend="number of employees",
        type="value")

1 个答案:

答案 0 :(得分:0)

感谢您的提问。 (但是?)可能无法更改定量树图的类别数。但是,您可以创建分类树图:

library(treemap)
data(business)
business <- transform(business, empCat = cut(employees, breaks = c(0, 3000, 6000, 9000, 
    14000), include.lowest = TRUE, right=FALSE))

treemap(business,
    index=c("NACE1", "NACE2"),
    vSize="employees",
    vColor="empCat",
    type="categorical", 
    palette="Greens",
    title.legend="number of employees",
    position.legend = "bottom")