SymbolixAU / colourvalues

R library for assigning colours to values
https://symbolixau.github.io/colourvalues/
46 stars 6 forks source link

summaries and formats #34

Closed SymbolixAU closed 5 years ago

SymbolixAU commented 6 years ago

TODO

POSIXct timezones (currently goes to UTC) summary_alpha - use na_colour + alpha <- not going to do user-supplied vector of summary values? like 'bins'~ <- don't remember what this was about


Example format_type

Rcpp::CharacterVector cls = getRClass( palette_type );
      if( is_in( "Date", cls ) ) {
        format_type = "Date";
      } else if ( is_in("POSIXct", cls) ) {
        format_type = "POSIXct";
      } else if ( is_in("logical", cls) ) {
        format_type = "logical";
      } else if ( is_in("character", cls) ) {
        format_type = "character";
      } else {
        format_type = "numeric";
      }

For example, if NAs are included in the vector, should they also be included in the summary, AND should the alpha values be in the summary too?

x <- 1:10
x[c(3,9)] <- NA

colour_values(x, alpha = 1:10, n_summaries = 5)
$colours
 [1] "#44015400" "#4828781C" "#808080FF" "#31688E55" "#26838E71" "#1F9D898D" "#35B779AA" "#6CCE59C6" "#808080FF"
[10] "#FDE725FF"

$summary_values
[1] "1.00"  "3.25"  "5.50"  "7.75"  "10.00"

$summary_colours
[1] "#440154FF" "#3B528BFF" "#21908CFF" "#5DC963FF" "#FDE725FF"

integers

Integers - the summary values become doubles

colour_values(1L:20L, n_summaries = 5)
#...
$summary_values
[1]  1.00  5.75 10.50 15.25 20.00
#...

specifying digits = 0 will turn the 5.75 to 6...

colour_values(1L:20L, n_summaries = 5)
#...
$summary_values
[1]  1  6 10 15 20
#...

is this right?