https://www.r-pkg.org/badges/version/rnbp https://cranlogs.r-pkg.org/badges/grand-total/rnbp
The rnbp package is an R wrapper for the National Bank of Poland API: https://api.nbp.pl/
The rnbp package is available on CRAN, you can install it with:
install.packages("rnbp")
You can install the the development version of rnbp from GitHub with:
# install.packages("devtools")
::install_github("szymanskir/rnbp") devtools
library(rnbp)
library(ggplot2)
## Retrieve current C exchange rate table
<- get_current_exchangerate_table("C")
response
## Retrieve content from the response
<- response$content$rates[[1]]
current_exchangerate_table
ggplot(current_exchangerate_table, aes(x = code, y = bid, fill = code)) +
geom_bar(stat = "identity")
## Retrieve last 20 exchange rates for euros
<- get_last_n_exchangerates("A", "EUR", 20)
euros_response
## Retrieve last 20 exchange rates for euros
<- get_last_n_exchangerates("A", "USD", 20)
dollars_response
## Retrieve rates data
<- euros_response$content$rates
euros_data <- dollars_response$content$rates
dollars_data
## Add currency code columns
$code <- euros_response$content$code
euros_data$code <- dollars_response$content$code
dollars_data<- rbind(euros_data, dollars_data)
currency_data
ggplot(currency_data, aes(x = effectiveDate, y = mid, col = code)) +
geom_line() +
geom_point()
<- Sys.Date()
current_date <- get_goldprice_from_interval(current_date - 90, current_date)
response
ggplot(response$content, aes(x = data, y = cena)) +
geom_point() +
geom_line() +
geom_smooth(method = "loess", formula = y ~ x)