有没有办法我可以手动控制各个范围的阈值? [英] Is there a way that I can manually control the thresholds between various range on choroplethr?

查看:84
本文介绍了有没有办法我可以手动控制各个范围的阈值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在choroplethr程序包上手动控制总体范围之间的阈值.

I would like to be able to manually control the thresholds between population ranges on choroplethr package.

library(choroplethr)

data(df_pop_county)        
data(continental_us_states)

county_choropleth(df_pop_county, 
                  state_zoom = continental_us_states)

推荐答案

您可以使用cut创建自定义间隔:

You can use cut to create the custom breaks:

# 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"))

这篇关于有没有办法我可以手动控制各个范围的阈值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆