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...
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...
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...
DataCamp offers interactive R, Python, Sheets, SQL and shell courses. All on topics in data science, statistics and machine learning. Learn from a team of expert teachers in the comfort of your browser with video lessons and fun coding challenges and projects. DataCamp offers many data science...
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...
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...
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.
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...
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...
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...
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...
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[] =...
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...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Stay connected