Hint: Go to DataCamp Course: Introduction to R for Finance. Watch the videos in Ch1: The Basics.
The three most basic data types are numeric data (ex. 42, 54), character data (ex. “hello world”, “forty”), and logicals (ex. TRUE, FALSE).
Hint: Go to DataCamp Course: Introduction to R for Finance. Chapter names are common types of R objects.
R’s five most common types of objects are vectors, matrices, data frames, factors, and lists.
Hint: Go to DataCamp Course: Introduction to R for Finance. Watch the videos in Ch2: Vectors and Matrices in.
A vector is a collection of data that are all the same type. A matrix is a 2D vector, it gives an extension to a vector to have columns and rows. In both vectors and matrices, you can only have one type of data.
Hint: Go to DataCamp Course: Introduction to R for Finance. Watch the videos in Ch3: Data Frames.
Data frames are used to store a data table. A data frame has a similar look to a matrix with columns and rows, but in a data frame you can have multiple data types in a single data frame. With a data frame you could have a name in one column and a price in another, whereas with a matrix you can only have one data type.
## company cash_flow year
## 1 A 1000 1
## 2 A 4000 3
## 3 A 550 4
## 4 B 1500 1
## 5 B 1100 2
## 6 B 750 4
## 7 B 6000 5
Hint: Go to DataCamp Course: Introduction to R for Finance. Click on your first data.frame() in Ch3: Data Frames; Copy the code in script.R; and then paste it in the R code chunk above.