# NOT RUN {
data <- iris[10:29, ]
## By default, the colors_scales() function uses a blue-white-orange three-color pattern
reactable(data,
columns = list(
Petal.Length = colDef(style = color_scales(data))))
## If only two colors are desired,
## you can specify them with colors = 'c(color1, color2)';
reactable(data,
columns = list(
Petal.Length = colDef(style = color_scales(data,
colors = c("red", "green")))))
## Apply color_scales() across all numeric columns using reactable::defaultColDef
reactable(data,
defaultColDef = colDef(style = color_scales(data)))
## Use span to apply colors to values in relation to the entire dataset
reactable(data,
defaultColDef = colDef(style = color_scales(data, span = TRUE)))
## Span can take column names
reactable(data,
defaultColDef = colDef(style = color_scales(data, span = c("Sepal.Length", "Sepal.Width"))))
## Or it can also take column positions instead
reactable(data,
defaultColDef = colDef(style = color_scales(data, span = 1:2)))
# }
Run the code above in your browser using DataLab