I am trying to create a dummy variable in my dataset in R for the weekend, i.e. the column has a value of 1 when the day is on weekends and a value of 0 when the day is during the week.
At first I tried to iterate over the entire dataset on a row and assign the weekend variable 1 if the date is on the weekend. But this requires forever, because there are ~ 70,000 lines, and I know that there is a much simpler way, I just can not understand.
Below I want the dataframe core to look. Now it looks, except for the weekend column. I do not know if this will change anything, but now the date is a factor. I also have a list of weekend dates:
weekend <- c("2/9/2013", "2/10/2013", "2/16/2013", "2/17/2013", ... , "3/2/2013") date hour weekend 2/10/2013 0 1 2/11/2013 1 0 .... .... ....
thanks for the help
source share