Hi I am having trouble generating dummy variables for multiple different years.
So my data is a dataset of Guyana's GDP per capita from 1960 to 2019 (image attached). I have to generate dummy variables for the Great Recession, with 0 for 2007-2009 and 1 for other years for regression.
I use the ifelse() code to generate the dummy variables. If my code is GFC<-ifelse(data3$Year== "1/1/2007", 0, 1) then R successfully generated the dummy variable for year 2007 at 0. However, if I try to combine all 3 years to have them all be at 0 with the code GFC<-ifelse(data3$Year==c(1/1/2007, 1/1/2008, 1/1/2009), 0, 1), instead of getting a 0 at 2007-2009, all of the dummy variable would be 1.
How do I fix my code to get R to generate the dummy variable correctly?