Question
Please finish it in R language the dataframe should be called msft 1. Write a function called calculateret() to calculate the daily return. This function
Please finish it in R language
the dataframe should be called msft
1. Write a function called calculateret() to calculate the daily return. This function should have two arguments: msft(a data.frame object) and MSFT.Adjusted.
Daily return equals (closing price-opening price)/opening price
Call these returns retmsft
(This function should extract the prices for the variable indicated by MSFT.Adjusted and output the simple daily return from those prices. Please provide your function.)
2. To remove any NA's in retmsft, the code should be?
3. The mean of retmsft is? The sd of retmsft is?(solve in code)
MSFT.Open | MSFT.High | MSFT.Low | MSFT.Close | MSFT.Volume | MSFT.Adjusted | |
---|---|---|---|---|---|---|
1 | 12 | 13 | 11 | 12 | 10000 | 13 |
2 | 12 | 15 | 11 | 14 | 12000 | 14 |
3 | 13 | 16 | 9 | 15 | 10000 | 12 |
4 | 14 | 17 | 10 | 12 | 20000 | 11 |
5 | 12 | 14 | 11 | 13 | 3000 | 15 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started