0

I started learning R three days ago so pls bear with me.... if you see any flaws in my code or calculations please call them out.

I have tried this, but get a error message every time:

table.AnnualizedReturns(Apple.Monthly.Returns[, 2:3, drop = FALSE], scale = 12, 
                    Rf = 0, geometric = TRUE, digits = 4)

Error in checkData(R) : The data cannot be converted into a time series. If you are trying to pass in names from a data object with one column, you should use the form 'data[rows, columns, drop = FALSE]'. Rownames should have standard date formats, such as '1985-03-15'.

As you can clearly see I have no clue what I am doing.

This is every line of code I have written this far:

Dates <- Data_Task2$`Names Date`[1801:2270]
as.numeric(Dates)
Dates <- ymd(Dates)
Monthly.Return <- Data_Task2$Returns[1801:2270]
Monthly.Return <- as.numeric(Monthly.Return)
Apple.Monthly.Returns <- data.frame(Dates, Monthly.Return)
Log.return = log(Monthly.Return + 1)
Apple.Monthly.Returns$Log.return = log(Apple.Monthly.Returns$Monthly.Return + 1)
camille
  • 16,432
  • 18
  • 38
  • 60
  • [See here](https://stackoverflow.com/q/5963269/5325862) on making an R example that folks can help with, including a sample of data and what packages you're using – camille Sep 28 '20 at 17:03

1 Answers1

0

You should check out the Tidyverse and specifically dplyr (https://dplyr.tidyverse.org/).

This gets you to a good starting point: https://www.r-bloggers.com/2014/03/using-r-quickly-calculating-summary-statistics-with-dplyr/

Alexa
  • 21
  • 2