I have a data with year
variable 1950-2007, however, each year
is repeated 12 times because of the "month" variable in the other column. How can i create a year dummy variable? this is what i have and R is not accepting it
yeardummy <- cut(research$year, br=c(0, 1950:2007), labels=c("1950:2007"))
Here is a function I use for creating multiple dummy variables for each year in my data set.
Just pass variable from your dataset to it, and any prefix you want and it'll run through, then cbind to original dataset and you're good to go.
Hope this helps.