Created
November 15, 2025 20:26
-
-
Save bbolker/0bf38fc8f0c23f70f3979f30a09c022d to your computer and use it in GitHub Desktop.
Canadian dollar time series
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| download.file("https://fx.sauder.ubc.ca/etc/CADpages.pdf", dest = "CADpages.pdf") | |
| library(tabulapdf) | |
| xx <- extract_tables("CADpages.pdf") | |
| txt <- xx[[1]][[1]][-(1:4)] |> | |
| ## glitches | |
| gsub(pattern = "[[:alpha:]]", replacement = "") |> | |
| gsub(pattern = "-0.\\s+", replacement = " 0.") |> | |
| gsub(pattern = "-", replacement = "", fixed = TRUE) | |
| txt <- txt[-length(txt)] | |
| hdr <- strsplit(xx[[1]][[1]][4], " ")[[1]] | |
| vals <- read.table(text = txt, header = FALSE) | |
| names(vals) <- hdr | |
| png("CAD.png", width = 800, height = 400) | |
| par(las=1, bty = "l") | |
| plot(USD ~ Year, data = vals, type = "l", axes = FALSE, ylim = c(0.6, 1.1)) | |
| points(2025, 0.71, pch = 16) | |
| axis(side = 1, at = c(1950 + (0:7)*10, 2025)) | |
| axis(side = 2, at = (6:11)/10, labels = sprintf("$%1.2f", (6:11)/10)) | |
| abline(h=1, lty = 2) | |
| box() | |
| dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment