# colorNumeric

0th

Percentile

##### Color mapping

Conveniently maps data values (numeric or factor/character) to colors according to a given palette, which can be provided in a variety of formats.

##### Usage
colorNumeric(palette, domain, na.color = "#808080", alpha = FALSE)colorBin(palette, domain, bins = 7, pretty = TRUE, na.color = "#808080", alpha = FALSE)colorQuantile(palette, domain, n = 4, probs = seq(0, 1, length.out = n + 1),
na.color = "#808080", alpha = FALSE)colorFactor(palette, domain, levels = NULL, ordered = FALSE, na.color = "#808080",
alpha = FALSE)
##### Arguments
palette
The colors or color function that values will be mapped to
domain
The possible values that can be mapped.

For colorNumeric and colorBin, this can be a simple numeric range (e.g. c(0, 100)); colorQuantile needs representative numeric data; and colorFactor

 na.color The color to return for NA values. Note that na.color=NA is valid. alpha Whether alpha channels should be respected or ignored. If TRUE then colors without explicit alpha information will be treated as fully opaque. bins Either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which the domain values are to be cut. pretty Whether to use the function pretty() to generate the bins when the argument bins is a single number. When pretty = TRUE, the actual number of bins may not be the number of bins you n Number of equal-size quantiles desired. For more precise control, use the probs argument instead. probs See quantile. If provided, the n argument is ignored. levels An alternate way of specifying levels; if specified, domain is ignored ordered If TRUE and domain needs to be coerced to a factor, treat it as already in the correct order 
 
 Details colorNumeric is a simple linear mapping from continuous numeric data to an interpolated palette.colorBin also maps continuous numeric data, but performs binning based on value (see the cut function).colorQuantile similarly bins numeric data, but via the quantile function.colorFactor maps factors to colors. If the palette is discrete and has a different number of colors than the number of factors, interpolation is used.The palette argument can be any of the following: A character vector of RGB or named colors. Examples:palette(),c("#000000", "#0000FF", "#FFFFFF"),topo.colors(10) The name of an RColorBrewer palette, e.g. "BuPu" or "Greens". A function that receives a single value between 0 and 1 and returns a color. Examples: colorRamp(c("#000000", "#FFFFFF"), interpolate="spline"). Value A function that takes a single parameter x; when called with a vector of numbers (except for colorFactor, which expects factors/characters), #RRGGBB color strings are returned (unless alpha=TRUE in which case #RRGGBBAA may also be possible). Aliases colorBin colorFactor colorNumeric colorQuantile Examples pal = colorBin("Greens", domain = 0:100) pal(runif(10, 60, 100)) # Exponential distribution, mapped continuously previewColors(colorNumeric("Blues", domain = NULL), sort(rexp(16))) # Exponential distribution, mapped by interval previewColors(colorBin("Blues", domain = NULL, bins = 4), sort(rexp(16))) # Exponential distribution, mapped by quantile previewColors(colorQuantile("Blues", domain = NULL), sort(rexp(16))) # Categorical data; by default, the values being colored span the gamut... previewColors(colorFactor("RdYlBu", domain = NULL), LETTERS[1:5]) # ...unless the data is a factor, without droplevels... previewColors(colorFactor("RdYlBu", domain = NULL), factor(LETTERS[1:5], levels = LETTERS)) # ...or the domain is stated explicitly. previewColors(colorFactor("RdYlBu", levels = LETTERS), LETTERS[1:5]) Documentation reproduced from package leaflet, version 1.0.0, License: GPL-3 | file LICENSE Community examples Looks like there are no examples yet. Post a new example: 
 
 
 R package Rdocumentation.org Created by DataCamp.com 
 Learn R at work MathJax.Hub.Config({ messageStyle: "none", jax: ["input/TeX","output/CommonHTML"], extensions: ["tex2jax.js","MathMenu.js","MathZoom.js"], TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] }, tex2jax: { inlineMath: [ ['$','$'], ['\$','\$'] ], displayMath: [ ['$$','$$'] ], processEscapes: true, preview: 'none' } }); var $jq = jQuery.noConflict(); ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//cdn.datacamp.com/sp/2.9.3.js","snowplow")); var options = { appId: 'rdocumentation', platform: 'web', post: true, discoverRootDomain: true, contexts: { webPage: true, performanceTiming: true } }; options.forceSecureTracker = true; options.postPath = '/spevent'; window.snowplow('newTracker', 'co', "www.datacamp.com", options); window.snowplow('enableActivityTracking', 10, 10); // Ping every 10 seconds after 10 seconds window.snowplow('enableLinkClickTracking'); window.snowplow('trackPageView', null, [ { schema: 'iglu:com.datacamp/user/jsonschema/1-0-0', data: { anonId:$jq.cookie('dc_aid'), } } ]); var config = { forms: { whitelist: ["snowplow_tracked"] }, fields: { blacklist: ['password', 'password_confirmation'] } }; window.snowplow('enableFormTracking', config); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-41577880-1', 'rdocumentation.org'); ga('send', 'pageview');