ggradar R Package

repository·master·Indexed 43 days ago

https://github.com/ricardo-bion/ggradar

An R package for creating radar charts (spider charts) using the ggplot2 framework. It provides improved aesthetics and compatibility with ggplot2 2.0, allowing for custom fonts via the font.radar argument and integration with pipe workflows.

Tokens
553
Snippets
3
Records
3
Agent score
6%

What's inside ggradar

  1. Use custom fonts in `ggradar`

    master

    You can customize the typography of your radar chart using the font.radar argument. To use a custom font:

    1. Download the font file to your system.
    2. Install the font on your operating system.
    3. Register the font in R using the extrafont package.
    4. Pass the font family name to the font.radar parameter in ggradar().

    ggradar can be used directly in a pipe (%>%) workflow.

    # Example using a custom font 'Circular Air' in a pipe
    mtcars %>% 
      as_tibble(rownames = "group") %>% 
      mutate_at(vars(-group), rescale) %>% 
      tail(4) %>% 
      select(1:10) %>% 
      ggradar(font.radar = "Circular Air")
  2. Create a radar chart with `ggradar()`

    master

    To use ggradar, prepare a data frame where one column (e.g., group) contains the labels for the radar axes, and the remaining columns contain the numeric values. It is highly recommended to rescale your numeric values (e.g., using scales::rescale) so they fall within a consistent range (typically 0 to 1) before plotting.

    library(ggradar)
    library(dplyr)
    library(scales)
    library(tibble)
    
    # Prepare data: convert to tibble, rescale numeric columns, and select features
    mtcars_radar <- mtcars %>% 
      as_tibble(rownames = "group") %>% 
      mutate_at(vars(-group), rescale) %>% 
      tail(4) %>% 
      select(1:10)
    
    # Generate the radar chart
    ggradar(mtcars_radar)