Fundamentals of R
The course is part of this learning path
This module introduces you to the some of the basic data structures that can be used in R
The objectives of this module are to provide you with an understanding of:
- What a vector is in R
- How to create a sequence
- How to create a vector using a repetition
- How to pull elements out of vectors
- Vectorised operations
- Logical comparisons
- Strings in R
- Undefined situations in mathematics
- 0, NA, NaN, & Null
Aimed at all who wish to learn the R programming language.
No prior knowledge of R is assumed
Delegates should already be familiar with basic programming concepts such as variables, scope and functions
Experience of another scripting language such as Python or Perl would be an advantage
Having an understanding of mathematical concepts will be beneficial
We welcome all feedback and suggestions - please contact us at firstname.lastname@example.org to let us know what you think.
- [Narrator] To pull elements out of vectors, we can use index notation. Here I've created my prices vector and I'd like to know what is the third element. I can use open brackets three closed brackets to return the third item or the third element of this vector. How would I get the last entry? Well I can see physically with my eyes, as this vector is quite small, that there are only four entries, so I can use a bit of wisdom and say that the fourth entry would be the one that I'm after. But if I wanted to be smart about this and assuming that the prices vector could be including any number of prices data, I would use perhaps the length function, and then call the index based on this variable that I've just created. I don't have to use the assigned variable, I could use length directly. How could I get the penultimate entry? I could use the argument that we've used already, which is I can see that there are four entries, so the penultimate one would be the third entry and I can call prices with the third index and I could obtain the third element. But what would be smarter is I could use the length of prices minus one to return the penultimate entry. Can I retrieve both the first and the third element? I can do that by calling the index of the vector of one and three. What is C open brackets one comma three in this used case of prices? Open square brackets C open round brackets one comma three close round brackets close square brackets. I can see that it is defined as a vector if I press enter, but this is the indices that we are gonna be asking for access within that vector known as prices. What does a negative index mean? So a negative index informs which elements we would like to reject. For example, if I take prices and I ask for without the first entry, I could say minus one, and that drops five from the vector that is outputted. Say for example I wanted to remove every odd entry, the first and the third. I could remove the 5 and the 10 and return just the remaining six and four to the screen. What if I wanted to remove the last entry? Again, we know it's only 4 elements long, so we could use minus four. Imagining a world where the prices vector is slightly longer and more complicated, we could use minus length of prices as our index.
Kunal has worked with data for most of his career, ranging from diffusion markov chain processes to migrating reporting platforms.
Kunal has helped clients with early stage engagement and formed multi week training programme curriculum.
Kunal has a passion for statistics and data; he has delivered training relating to Hypothesis Testing, Exploring Data, Machine Learning Algorithms, and the Theory of Visualisation.
Data Scientist at a credit management company; applied statistical analysis to distressed portfolios.
Business Data Analyst at an investment bank; project to overhaul the legacy reporting and analytics platform.
Statistician within the Government Statistical Service; quantitative analysis and publishing statistical findings of emerging levels of council tax data.
Structured Credit Product Control at an investment bank; developing, maintaining, and deploying a PnL platform for the CVA Hedging trading desk.