2016-12-06 36 views

回答

3

您可以使用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")) 

enter image description here

+0

太謝謝你了! – dananta

相關問題