Disclaimer: The content of this RMarkdown note came from a course called Introduction to R for Finance in datacamp.
What are R’s three most basic data types? Of the three, what would be decimal numbers like 3.1? Type your answer below.
Characters, Numerical, and Logical. A decimal such as 3.1 would be Numerical.
What are R’s five most common types of objects? Type your answer below.
Vectors, Matrices, data frames, factors, and lists
Compare vectors and matrices. What are similarities and differences? Type your answer below.
Vectors and matrices are similiar because they are both structures that only deal with one type of data. They are different because Vectors are one demensional and matrices are two demensional. Also Matrices have rows and columns while vectors are just rows.
Compare matrices and data frames. What are similarities and differences? Type your answer below.
Matrices and data frames are similiar because they are both data structures that are two dimensional. They are different because matrices are homogeneous and data frames are not.
Create a vector, “returns”, in place of “ret”; and assign 5 return values, 1 through 5 in place of (5, 2, 3, 7, 8, 3, 5, 9, 1, 4, 6, 3). Create another vector, “days”, in place of “months”; and assign 5 days, Monday through Friday in place of (“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”). Then, create a data frame, “daily_returns”, in place of “monthly_returns” by combining days and returns.
## days returns
## 1 mon 1
## 2 tue 2
## 3 wed 3
## 4 thu 4
## 5 fri 5
Subset rows with daily returns greater than or equal to 4%.
## days returns
## 4 thu 4
## 5 fri 5