# NOT RUN {
data <- iris[10:29, ]
## By default, the colors_tiles() function uses a blue-white-orange three-color pattern
reactable(data,
columns = list(
Petal.Length = colDef(cell = color_tiles(data))))
## If only two colors are desired,
## you can specify them with colors = 'c(color1, color2)';
reactable(data,
columns = list(
Petal.Length = colDef(cell = color_tiles(data,
colors = c("red", "green")))))
## Use span to apply colors to values in relation to the entire dataset
reactable(data,
defaultColDef = colDef(cell = color_tiles(data, span = TRUE)))
## Span can take column names
reactable(data,
defaultColDef = colDef(cell = color_tiles(data, span = c("Sepal.Length", "Sepal.Width"))))
## Or it can also take column positions instead
reactable(data,
defaultColDef = colDef(cell = color_tiles(data, span = 1:2)))
## Use number_fmt to format numbers using the scales package
car_prices <- MASS::Cars93[20:49, c("Make", "Price")]
reactable(car_prices,
defaultColDef = colDef(cell = color_tiles(car_prices,
number_fmt = scales::dollar)))
# }
Run the code above in your browser using DataLab