How to use pafdR

Marcelo Perlin

2017-04-29

Package pafdR provides access to all material from book Processing and Analyzing Financial Data with R. You can find more details here.

With pafdR you can:

  1. Download data and code with function pafdR_download.code.and.data
  2. Build exercises with function pafdR_build.exercise

Downloading code and data

All the R code from the book is publicly available in github. Function pafdR_download.code.and.data will download a zip file from the repository and unzip it at specified folder. Have a look in its usage:

if (!require(pafdR)){
  install.packages('pafdR')
  library(pafdR)
} 

my.lan <- 'en' # language of code and data ('en' or 'pt-br')

# dl may take some time (around 60 mb)
pafdR_download.code.and.data(lan = my.lan)

dir.out <- 'pafdR-en-code_data-master'

# list R code
list.files(dir.out, pattern = '*.R')
list.files(paste0(dir.out,'/data'))

Building exercises

All exercises from the book are based on package exams. This means that every reader will have a different version of the exercise, with different values and correct answer. I’ve written extensively about the positive aspects of using exams. You can find the full post here

You can create your custom exercise file using function pafdR_build.exercise. Give it a try, just copy and paste the following chunk of code in your R prompt.

if (!require(pafdR)){
  install.packages('pafdR')
  library(pafdR)
} 

my.lan <- 'en' # language of exercises
my.exercise.folder <- 'pafdR-exercises' # name of folder with exercises files (will download from github)
my.pdf.folder <- 'PdfOut' # name of folder to place pdf file and answer sheet

pafdR_build.exercise(lan = my.lan,
                     exercise.folder = my.exercise.folder, 
                     pdf.folder = my.pdf.folder)

list.files(my.pdf.folder)