The goal of {fivestars} is to generate star ratings with HTML and CSS.

Installation

Install the development version from GitHub with:

install.packages("fivestars", repos = "https://tanho63.r-universe.dev")

# or use remotes/devtools
# install.packages("remotes")
remotes::install_github("tanho63/fivestars")

Usage

use_fivestars() adds the appropriate CSS and allows for some configuration of defaults (star size, colour, and background).

use_fivestars(
  star_size = "20px", # default is "larger"
  star_color = "#fc0", # default
  star_background = "#999" # default
)

Minimal usage of the fivestar function looks like this:

fivestars(rating = 3.5)

3.5


The output can be further customized with some arguments, e.g.

fivestars(rating = 1.2,
         label = "Poor",
         label_pos = "right",
         aria_label = "This item is rated 'Poor'",
         star_color = "#d13", 
         star_background = "#000")

Poor