r-programming

  1. enjofaes

    R code used for slides / reporting

    Hi David, This is a proposition (don't know if it is super difficult to do). But could you maybe add the r code you use or are working on for certain topics in the FRM? I know that certainly many will be interested as FRM is becoming more and more centric on data science techniques (also the...
  2. Nicole Seaman

    YouTube T5-03: Expected shortfall: approximating continuous, with code

    In our previous video, we showed how we retrieve expected shortfall under the simplest possible discrete case. That was a simple historical simulation, but that was discrete. In this video, we will review the expected shortfall when the distribution is continuous. Specifically, we will use the...
  3. Nicole Seaman

    YouTube R Finance-01: Load historical stock price series

    In this video, I'm excited to share one approach to importing historical stock price series into R. I think there are different ways to do this. My approach here is inspired by the approach that is illustrated by Jonathan Regenstein and his excellent book, Reproducible Finance with R, which you...
  4. Nicole Seaman

    YouTube R Programming: Introduction: ggplot for capital market line (CML, R Intro-08)

    In this video, I'd like to show you the bare minimum of what we need to know to render a visualization in ggplot. The bare minimum is that we need to use the three essential layers (three out of seven possible). Those three essential layers are data, aesthetics, and giome (short for geometries...
  5. Nicole Seaman

    YouTube R Programming Tidyverse: readr package to import data (csv, tab-separated, fixed-width) (tidy-02)

    David introduces the package that's called readr, which is part of the tidy verse, and this is the package that we would use to import external files into our R environment as usable R objects. In the tidy verse those would be called Tibbles, but a Tibble is just an enhanced user-friendly...
  6. Nicole Seaman

    YouTube R Programming Intro: Load flat/CSV/excel file with built-in read.table function or readxl (intro-07)

    read.table() is the core function for loading files external file into R dataframes; it is part of the utils package which is automatically loaded when you start R. Aside from the header argument, the sep and quote arguments define the field separators. The read.csv() function is a wrapper...
  7. Nicole Seaman

    YouTube R Programming Tidyverse: What is tidy data?

    Tidy data meets three conditions: 1. Each variable must have its own column; 2. each observation must have its own row; and 3. Each value must have its own cell.
  8. Nicole Seaman

    YouTube R Programming: Introduction: How to subset (R intro-06)

    R has three subset operators: [, [[, and $. Given data frame df, both of these return a data frame: df["z"], df[3]. Given a data frame df, all three of these commands are identical and return a vector: df$z, df[["z"]], df[[3]]. David's script is here...
  9. Nicole Seaman

    YouTube R Programming Introduction: Matrices (R intro-05)

    In R a matrix is an atomic vector with the dimension attribute. In this example, the correlation matrix is entered as a vector with sixteen elements: rho_v <-c(1.000, ...). Then the vector is translated into a matrix with rho <- matrix(rho_v, nrow = 4, ncol =4). Now it is a matrix because it has...
  10. Nicole Seaman

    YouTube R Programming: Introduction: Factors (R Intro-04)

    Factors are categorical vectors. Specifically, they are (integer) vectors that store categorical values, or ordinal values. Ordinal values are *ranked* categories (but they are not intervals). Factors can only contain predefined values. A classic example of a factor are male/female. An example...
  11. Nicole Seaman

    YouTube R Programming: Introduction: Data Frames (R Intro-03)

    Data frames are the most common structure in R. A data frame is a list of equal-length vectors; ie, it's a rectangle. Create a data frame with data.frame(). Single-brackets, stocks[1], returns a dataframe. Double-brackets, stocks[[1]], returns a vector and is equivalent to stocks$ticker. We can...
  12. Nicole Seaman

    YouTube R Programming: Introduction: List Data Structure (R Intro - 02)

    Unlike atomic vectors, list (vectors) are flexible: each element can be a different type (char, integer, numeric, logical or even a sub-list!). List returns the i-th element as a list, while list[] returns the element as a vector. If the element is named, then list[["name"]] = list[] =...
  13. Nicole Seaman

    YouTube R Programming: Introduction (Atomic Vectors) (R Intro-01)

    Vectors are natural to R. David starts by creating a numeric vector with the command: three_dice <- c(2, 3, 6). He forgot to mention in the video that "c" here stands for "combine," as in we are "combining these three values as elements in a new vector called three_dice." We can think of this as...
Top