Learn R Programming

qatarcars (version 1.1.0)

currency_conversion: Convert between QAR, USD, and EUR

Description

Functions to convert between Qatari Riyals (QAR), US Dollars (USD), and Euros (EUR) using exchange rates from the time of data collection in January 2025.

Usage

qar_to_usd(qar)

qar_to_eur(qar)

usd_to_qar(usd)

usd_to_eur(usd)

eur_to_qar(eur)

eur_to_usd(eur)

Value

Numeric vector of converted currency amounts

Arguments

qar

numeric vector of values in Qatari Riyals

usd

numeric vector of values in US Dollars

eur

numeric vector of values in Euros

Details

Exchange rates in January 2025:

  • 1 USD = 3.64 QAR

  • 1 EUR = 4.15 QAR

Examples

Run this code
qar_to_usd(100)
usd_to_eur(50)
eur_to_qar(25)

qatarcars$price_eur <- qar_to_eur(qatarcars$price)
qatarcars$price_usd <- qar_to_usd(qatarcars$price)
qatarcars[, c("origin", "make", "model", "price", "price_eur", "price_usd")]

# Labels are updated automatically
str(qatarcars$price)
str(qatarcars$price_eur)
str(qatarcars$price_usd)

if (require("dplyr")) {
  qatarcars |> 
    mutate(
      price_eur = qar_to_eur(price), 
      price_usd = qar_to_usd(price)
    ) |> 
    select(origin, make, model, starts_with("price"))
}

Run the code above in your browser using DataLab