Last updated: 2021-05-21

Checks: 7 0

Knit directory: stat34800/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20180411) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 5d15ff0. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  data/currency.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/currency.Rmd) and HTML (docs/currency.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 5d15ff0 Matthew Stephens 2021-05-21 workflowr::wflow_publish(“currency.Rmd”)
html af3fd49 Matthew Stephens 2021-05-20 Build site.
Rmd 89306e1 Matthew Stephens 2021-05-20 workflowr::wflow_publish(“currency.Rmd”)

Introduction

I wanted to download some exchange rate data

We can get a table of currencies from quantmod:

currency_table = quantmod::oanda.currencies
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
head(currency_table)
    oanda.df.1.length.oanda.df...2....1.
USD                            US Dollar
AFN                  Afghanistan Afghani
ALL                         Albanian Lek
DZD                       Algerian Dinar
ADF                       Andorran Franc
ADP                      Andorran Peseta

I want to get all the exchange rates, so I use USD as the standard. The getFX function saves object to environment, so I put it in a dataframe. Then I save them to data/currency.csv.

library(quantmod)
Warning: package 'quantmod' was built under R version 3.6.2
Loading required package: xts
Warning: package 'xts' was built under R version 3.6.2
Loading required package: zoo
Warning: package 'zoo' was built under R version 3.6.2

Attaching package: 'zoo'
The following objects are masked from 'package:base':

    as.Date, as.Date.numeric
Loading required package: TTR
Warning: package 'TTR' was built under R version 3.6.2
curr = rownames(quantmod::oanda.currencies) # gives the 3-letter abbreviation
df = data.frame(matrix(0,ncol= length(curr),nrow=179))
for(i in 1:length(curr)){
  xrate = getFX(paste0("USD/",curr[i]))  # get the exchange rates of all currencies with USD)
  xrate = get(paste0("USD",curr[i]))
  df[,i] = xrate
}
colnames(df) <- curr
write.csv(df, file="../data/currency.csv",quote=FALSE,row.names=FALSE)

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4.18 TTR_0.24.2      xts_0.12.1      zoo_1.8-8      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6       rstudioapi_0.13  whisker_0.4      knitr_1.29      
 [5] magrittr_1.5     workflowr_1.6.2  lattice_0.20-41  R6_2.4.1        
 [9] rlang_0.4.10     stringr_1.4.0    tools_3.6.0      grid_3.6.0      
[13] xfun_0.16        git2r_0.27.1     htmltools_0.5.0  ellipsis_0.3.1  
[17] yaml_2.2.1       digest_0.6.27    rprojroot_1.3-2  tibble_3.0.4    
[21] lifecycle_1.0.0  crayon_1.3.4     later_1.1.0.1    vctrs_0.3.4     
[25] fs_1.5.0         promises_1.1.1   curl_4.3         glue_1.4.2      
[29] evaluate_0.14    rmarkdown_2.3    stringi_1.4.6    compiler_3.6.0  
[33] pillar_1.4.6     backports_1.1.10 jsonlite_1.7.2   httpuv_1.5.4    
[37] pkgconfig_2.0.3