【问题标题】:Is there a way that I can manually control the thresholds between various range on choroplethr?有没有一种方法可以手动控制 choroplethr 上各个范围之间的阈值?
【发布时间】:2016-12-06 19:29:27
【问题描述】:

我希望能够手动控制choroplethr 包上的人口范围之间的阈值。

library(choroplethr)

data(df_pop_county)        
data(continental_us_states)

county_choropleth(df_pop_county, 
                  state_zoom = continental_us_states)

【问题讨论】:

    标签: r choropleth choroplethr


    【解决方案1】:

    您可以使用cut 创建自定义中断:

    # rename the original "value" column if you don't want to write over it
    names(df_pop_county) <- c("region", "original_value")
    
    # define the breaks you want
    df_pop_county$value <- cut(df_pop_county[["original_value"]],
                               breaks = c(0, 1e4, 5e4, 1e5, 5e5, 1e6, 1e7))
    # if you want custom labels to go along with those breaks, then provide
    # the labels argument in cut:
    # cut(df_pop_county[["original_value"]],
    #     breaks = c(0, 1e4, 5e4, 1e5, 5e5, 1e6, 1e7),
    #     labels =c( "0-9999","10000-49999", "50000-99999", "100000-499999", "500000-999999", "1000000-10000000"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-24
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多