Hi there,
I need to create a dummy variable where I set my values "Monthly_Total_Returns" equal to 1 in March 2020. 0 otherwise. The data is all aligned and organized. My variables' names (columns) are "Monthly_Total_Returns, where I find my values", "date, where there are my dates (month + year. e.g. "2020-03") of the years. Can you help me with that? This is what I have done so far.
Data$Monthly_Total_Returns
Monthly_Total_Returns_bad_march <- Data$Monthly_Total_Returns
Monthly_Total_Returns_bad_march %>%
filter(format(Date, format = "%Y-%m") == "2020-03", Data$Monthly_Total_Returns)
Monthly_Total_Returns_bad_march <- 1
My boss told me that I don't need to use the FILTER function and it should be easier and more straightforward. Please let me know.