I have the following data.frame:
dates <- sample(seq(as.Date('1999/01/01'), as.Date('2000/01/01'), by="day"), 12)
df <- data.frame(dates)
df$week_day <- weekdays(as.Date(df$dates))
I now would like to know whether the dates are actually a weekend day or now.
Therefore I have tried:
df$weekday <- as.character(df$week_day)
for (i in 1:nrow(df)) {
if(df$week_day[i] == "Saturday"){
df$Weekend[i] == 1
} else if (df$week_day[i] == "Monday"){
df$Weekend[i] == 1
}
}
This however does not work. Any thoughts why this is not working? And what I should do :).