Skip to contents

Set star rating formatter

Usage

set_formatter_star(widget, columns, number_of_stars = NA, hoz_align = "center")

Arguments

widget

A tabulator() HTML widget.

columns

The names of the columns the formatter is applied to.

number_of_stars

The maximum number of stars to be displayed. If set to NA, the maximum value of the column is used.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

data <- data.frame(
  Passengers = c("Hans", "Franz", "Ferdinand", "Julia"),
  PassengerClass = c(1, 2, 1, 3)
)

tabulator(data, width = 200) |>
  set_formatter_star("PassengerClass", number_of_stars = max(data$PassengerClass))