get_party_color_by_name: Get party color by name

View source: R/partyfacts.R

get_party_color_by_nameR Documentation

Get party color by name

Description

A convenience function that combines party lookup and color extraction. Searches for a party by name, finds its Wikipedia URL, and extracts the party color.

Usage

get_party_color_by_name(
  party_name,
  country = NULL,
  all_colors = FALSE,
  data = NULL
)

Arguments

party_name

A character string with the party name to search for.

country

Optional. ISO 3-letter country code to filter results.

all_colors

Logical. If 'TRUE', returns all colors. Default is 'FALSE'.

data

Optional. A Partyfacts dataset.

Value

If exactly one party is found, returns the color(s). If multiple parties match, returns a tibble with party info and colors. Returns NA if no party is found.

Examples


if (curl::has_internet()) {
  # Get color for German SPD
  get_party_color_by_name("SPD", country = "DEU")

  # Search more broadly
  get_party_color_by_name("Labour", country = "GBR")
}


partycoloR documentation built on Jan. 28, 2026, 1:07 a.m.