A number alone is a poor research record. A US policy-rate observation also needs a date, a unit, a defined instrument and a source. This tutorial uses the FXMacroData R client to keep that context attached while making a small, inspectable comparison. It then places the rate readings beside daily EUR/USD reference rates without claiming that one caused the other.
The worked example uses the US policy_rate series, the federal funds target-range upper bound. The stored readings checked on 27 November 2026 were 4.0% on 16 September and 4.0% on 28 October. Both fit within the public USD 90-day sample at the time of writing. The charts also use Federal Reserve H.10 EUR/USD daily reference rates over the same bounded period. FX history requires a subscription key in the R client; the basic policy-rate comparison does not.
What you will make
You will retrieve a named series, inspect response metadata, turn its date and val columns into a dated numeric frame, compare the latest two observations, and save the original response beside the result. With an FX subscription key, the optional chart section adds spot context and a closer look at the days around each decision.
Keep the response and your analysis separately. A later reader should be able to see what the client returned and which rows your note used.
Watch the R workflow
This 41-second video replays an actual isolated R 4.5.3 run against the two stored USD policy-rate rows used below. It shows row validation, the dated comparison and an RDS save-and-read check. The sandbox had no network access, so the video does not show a live client request or an FX subscription response.
Read the video transcript
This is an offline R execution replay using two stored US policy-rate observations. The live client request is in the article. This sandbox uses the verified sample without network access.
The script checks for date and value, converts them to usable types, sorts the rows, and prints the last two observations before doing any arithmetic.
Both upper-bound readings are four percent. R computes a change of zero point zero zero percentage points, and the note keeps both dates beside the result.
The script saves the observations, series context, selected rows and note together. It then reads the R data file back and verifies that the saved note matches.
Prerequisites
- R with the FXMacroData R client installed. Pin the package revision in your project lockfile.
- No key for the public USD policy-rate sample. Set
FXMACRODATA_API_KEYin your R environment if you want to request EUR/USD history for the optional charts. Keep the key out of scripts and notebooks. - A working directory where R may save one
.rdssnapshot. Check your plan before sharing it.
The current public window is short. The code stops if fewer than two usable rows are returned instead of manufacturing a comparison.
1. Request one named series
Ask for one indicator and print its context before making a plot. The top-level response fields remain attached to the data frame and are available through fxmd_meta().
library(fxmacrodata)
rates <- fxmd_announcements("USD", "policy_rate", limit = 100)
if (!is.data.frame(rates) || nrow(rates) < 2L) {
stop("At least two observations are needed for this comparison")
}
context <- fxmd_meta(rates)
print(context[c("currency", "indicator", "unit", "pagination")])
if (!identical(context$unit, "%")) stop("Expected a percentage rate")
Check pagination before calling a page a complete history. A limit of 100 is a request size, not evidence that every observation was returned. The instrument is the upper bound of the target range, not the midpoint or the effective overnight rate.
2. Validate the rows you will use
Inspect the column names and make a separate, sorted working frame. Preserve rates untouched, with its metadata attached. A zero substituted for an absent value would create a false policy move, so missing fields and unusable rows get explicit checks.
needed <- c("date", "val")
missing <- setdiff(needed, names(rates))
if (length(missing)) stop("Missing columns: ", paste(missing, collapse = ", "))
sample <- rates[, needed, drop = FALSE]
sample$date <- as.Date(sample$date)
sample$val <- suppressWarnings(as.numeric(sample$val))
sample <- sample[!is.na(sample$date) & !is.na(sample$val), , drop = FALSE]
sample <- sample[order(sample$date), , drop = FALSE]
if (nrow(sample) < 2L) stop("Not enough usable dated observations")
print(tail(sample, 2L))
The print is a simple audit point. Read the dates and values before interpreting a difference. In this example the two checked rows have the same value, but a later run may return newer decisions. That is why the calculation below uses the response, not hard-coded numbers.
| Object | Keep it for |
|---|---|
rates |
Returned observations and attached response metadata |
context |
Series identity, unit and pagination information |
sample |
Dated numeric rows selected for this calculation |
3. Calculate the latest change
diff() subtracts the prior val from the latest val. Because the metadata check established a percent unit, the difference is in percentage points. This is a descriptive calculation across returned rows, not a forecast surprise or an estimate of market reaction.
last_two <- tail(sample, 2L)
change <- diff(last_two$val)
note <- sprintf(
"US target-range upper bound: %.2f%% on %s; prior %.2f%% on %s; change %+.2f percentage points.",
last_two$val[2], last_two$date[2],
last_two$val[1], last_two$date[1], change
)
cat(note, "\n")
For the stored rows checked on 27 November, that produces 4.0% on 28 October versus 4.0% on 16 September, or 0.00 percentage points. It says nothing about consensus. If a later response includes revisions or a different filter, inspect the full returned records before treating adjacent rows as consecutive policy decisions.
4. Read the rate beside spot context
The first chart starts the rate line at the first policy observation in this bounded sample. It does not draw an earlier rate from an unobserved row. The faint dashed EUR/USD line uses the right axis, in US dollars per euro. The different units and axes matter: 4.0% cannot be read against the spot-price scale.
The target-range upper bound was 4.0% at both observed decisions. EUR/USD moved during the same period. Their co-occurrence is context for a research question, not proof of a policy effect. The figure uses Federal Reserve policy statements for the rate readings and Federal Reserve H.10 for daily EUR/USD reference rates.
If your plan includes FX history, this base R code reproduces the chart structure from your current response. Inspect the spot response's source and returned dates before comparing it with the fixed H.10 illustration.
spot <- fxmd_forex("EUR", "USD", start_date = "2026-08-29", limit = 100)
if (!all(c("date", "val") %in% names(spot))) stop("Spot fields are missing")
fx <- spot[, c("date", "val"), drop = FALSE]
fx$date <- as.Date(fx$date)
fx$val <- suppressWarnings(as.numeric(fx$val))
fx <- fx[!is.na(fx$date) & !is.na(fx$val), , drop = FALSE]
fx <- fx[order(fx$date), , drop = FALSE]
fx <- fx[fx$date >= min(sample$date), , drop = FALSE]
if (nrow(fx) < 5L) stop("Not enough overlapping spot observations")
print(fxmd_meta(spot))
plot(fx$date, fx$val, type = "l", lty = 2, col = "#00e5ff",
xlab = "Date", ylab = "", axes = FALSE, xlim = range(fx$date))
axis.Date(1, at = pretty(fx$date))
axis(4)
mtext("EUR/USD, USD per EUR (right axis)", side = 4, line = 3)
par(new = TRUE)
plot(sample$date, sample$val, type = "s", lwd = 3, col = "#4cc2ff",
xlab = "", ylab = "US target-range upper bound (%)",
xlim = range(fx$date), ylim = range(c(sample$val, 3.8, 4.2)), axes = FALSE)
axis(2)
box()
legend("topright", c("Policy rate, left axis", "EUR/USD, right axis"),
col = c("#4cc2ff", "#00e5ff"), lty = c(1, 2), bty = "n")
The second chart narrows the view to the days around each decision. Each panel has its own vertical scale, printed in US dollars per euro; compare shape within a panel, not height across panels. A decision-date marker is a time reference, not a causal test.
With the same fx frame, make each window in R:
old_par <- par(mfrow = c(1, 2))
for (event in tail(sample$date, 2L)) {
around <- fx[abs(as.integer(fx$date - event)) <= 8L, , drop = FALSE]
if (nrow(around) < 5L) next
plot(around$date, around$val, type = "l", col = "#00e5ff",
xlab = "Date", ylab = "EUR/USD, USD per EUR",
main = format(event, "%d %b %Y"))
abline(v = event, col = "#ffd60a", lty = 2)
}
par(old_par)
The public figure uses the rights-cleared H.10 daily series held by FXMacroData. A subscription request may return a different eligible FX source or later rows, so record fxmd_meta(spot) and the returned dates when you regenerate it. Neither a daily fixing nor a policy-decision date establishes what the market knew at a particular intraday trading moment.
5. Save the evidence behind the note
Save the untouched client result, inspected context and text produced from the selected rows. This makes the calculation replayable from the saved response, even after a live endpoint has newer data.
snapshot <- list(
retrieved_at_utc = format(Sys.time(), tz = "UTC", usetz = TRUE),
observations = rates,
context = context,
selected_rows = last_two,
note = note
)
saveRDS(snapshot, "usd-policy-rate-research.rds")
replayed <- readRDS("usd-policy-rate-research.rds")
stopifnot(identical(replayed$note, note))
The file records what your script retrieved, not necessarily the values publicly available at an earlier decision time. A historical decision study needs each observation's publication and availability evidence. For this descriptive note, the saved rows, unit and retrieval time establish a narrower useful claim: what the current response said when you ran the script.
The workflow is complete: request a named series, retain its context, validate rows, compare dated values, add clearly labelled FX context if you have access, and save the evidence. Apply it to another indicator only after checking that indicator's unit, frequency and definition.
FXMacroData provides the official-source macro and FX data used by these illustrations. AI was used for research, creating images and editing.