- How to become wealthy: investing, equity, politics (NOT SALARY)
- Fundamental data: important data for data analysis
- Everything in R is a vector: if you don’t put in a value, automatically null
- Format for calculating compound returns: P*(1+R)^4 + P*(1+R)^3 + P*(1+R)^2 + P*(1+R)^1
- Creating arrays:
o b = c(1,5,7,2) #concatenates into an array
o b = 1:5 #creates an array from values 1 - 5, inclusive
o b = rep(3,5) #creates an array of the values "3" repeated 5 times
o b = seq(2,10,2) # creates an array between 2 and 10 inclusive, with increments of 2
o b = seq(10,2,-2) #to go backwards with seq, must have negative increment value
- IF/ELSE statement format
if(condition){
expr1 }
else{
expr2}
- FOR LOOPS
right side of for loop = vector you want to iterate through
left side of for loop = iterator, any variable name, becomes each value in the original vector, from left to right
a = 6:1
for(i in a){
print(i)
}
Prints: 6/5/4/3/2/1
- New Functions
o NROW(a) or length(a): Tells you how many values in the array
- Vector Mathematics
b = 1:5
b<3 #for each value of b, checks if it is less than 3 and returns "true" or "false"
o Slicing
b[1:3] #shows values of "b" between 1:3, inclusive
b[c(1,4)] #shows the values of "b" number 1 and 4, good for when desired values not next to each other
b[c(2:1,3,5)] #slices in the order that you require
o Logical Slicing
b[b<3] = b[b<3]+ 5 #This takes the result of the b<3 functions, and for whichever values of "b"
which are true, adds 5, Put simply, each value of "b" which is <3 (AKA 1,2) has 5
added to it
b[b>=3] = b[b>=3]-5 #This is like the first logical slice, but instead of affecting values <3, we affect
>=3, which is the remaining values
#This results in 3,4,5 transforming to -2,-1,0
- Uniroot: Uniroot will enter values into a function until the return is 0, and then give the input variable
$root = Answer, $f.root = final value of function, $iter = # of iterations
$init.it = ??, $estim.prec = how much memory was allocated to calculate answer
This study source was downloaded by 100000899606070 from CourseHero.com on 09-27-2025 21:02:42 GMT -05:00
https://www.coursehero.com/file/182188998/Investment-Modeling-Exam-1-study-guidedocx/