View source: R/assign.map.bins.R
assign.map.bins | R Documentation |
Takes a vector (not matrix or df) of values and returns a vector of bin numbers. For creating color-coded maps (choropleths), assign each place (e.g., each row of a single column) to a bin. Each bin represents one map color, and is defined by threshold values.
assign.map.bins(
pctiles.vector,
cutpoints = c((0:9)/10, 0.95, 1),
labels = 1:11
)
pctiles.vector |
Vector of percentiles as decimal fractions, 0 to 1, one per place. |
cutpoints |
Optional vector of cutpoints defining edges of bins. Default is every 0.10 from 0 to 1.00, as well as 0.95 |
labels |
vector of bin numbers, optional (default is 1 through 11, and NA values are put in bin 0). |
The default bins 0-11 are defined as follows:
bin 0: PCTILE=NA
...
bin 9: 0.80<=PCTILE<0.90
bin 10: 0.90<=PCTILE<0.95
bin 11: 0.95<=PCTILE<=1.00
Returns a vector bin numbers.
make.bin.pctile.cols()
and assign.pctiles()
junk<-c(0,0.799,0.8, 0.8000001, 0.8999999,0.95,0.95001,1)
data.frame(pctile=junk, bin=assign.map.bins(junk))
# How it puts these in bins by default:
# pctile bin notes
#1 0.0000000 1
#2 0.7990000 8
#
#3 0.8000000 9 (0.80<=PCTILE<0.90 )
#4 0.8000001 9 (0.80<=PCTILE<0.90 )
#5 0.8999999 9 (0.80<=PCTILE<0.90 )
#
#6 0.9000000 10 (0.90<=PCTILE<0.95 )
#7 0.9001000 10 (0.90<=PCTILE<0.95 )
#8 0.9499990 10 (0.90<=PCTILE<0.95 )
#
#9 0.9500000 11 (0.95<=PCTILE<=1.00 ) I.E. THIS INCLUDES 100th percentile
#10 0.9500100 11 (0.95<=PCTILE<=1.00 ) I.E. THIS INCLUDES 100th percentile
#11 1.0000000 11 (0.95<=PCTILE<=1.00 ) I.E. THIS INCLUDES 100th percentile
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.