how to use multiple conditions in "which" function in R?

Viewed 32

Trying to assign values for different set of dates and months over 50 years. For instance, for month = 1 & date = 1:14, value should be 1; month = 1, date = 15:31, value should be 2.. and so on

dataset used is "rdu"

rdu$weekset <- NA
rdu$weekset[which(rdu$Month == 1 & rdu$ Date == 1:14)] <- 1 

This is assigning random values of 1 to different set of dates and not abiding to month condition.

Tried different ways of putting "&" or bar, nothing giving standard results so far

WARNING shows "longer object length is not a multiple of shorter object length"

0 Answers
Related