View source: R/get_exchange_rate.R
| get_exchange_rate | R Documentation |
Downloads daily US dollar exchange rate (commercial, selling) from BCB/SGS. This function retrieves the daily exchange rate (SGS series 1) in Brazilian Real (R$).
get_exchange_rate(
start_date = NULL,
end_date = NULL,
language = "eng",
labels = TRUE
)
start_date |
Start date for the data period. Accepts multiple formats:
|
end_date |
End date for the data period. Accepts the same formats as
|
language |
Language for column names in the returned data.frame:
|
labels |
Logical indicating whether to add variable labels using the |
A data.frame with US dollar exchange rate. Columns depend on the language parameter:
English (language = "eng"): date (Date), exchange_rate (numeric, R$/US$)
Portuguese (language = "pt"): data_referencia (Date), taxa_cambio (numeric, R$/US$)
Series information: This function uses SGS series 1, which represents the commercial US dollar selling rate (taxa de câmbio livre - dólar americano - venda). Data is available from 1984 onward with daily frequency.
# Default: last 30 days of exchange rate
df <- get_exchange_rate()
# Specific period
df2 <- get_exchange_rate("2023-01-01", "2023-03-31")
# Using year-month format for a specific month
df3 <- get_exchange_rate("2023-06", "2023-06")
# Portuguese column names and labels
df4 <- get_exchange_rate(language = "pt")
# Complete example with all parameters
df5 <- get_exchange_rate("2023-01-01", "2023-12-31", language = "pt", labels = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.