Hi R,
I have a column with dates. I need to create a vector say from (current date-90 days: current date) For example I need to subtract 90 days from say Sys.Date()-92 If Sys.Date()-92 == "Sunday", Sys.Date()-92+1 if Sys.Date()-92 == "Saturday", Sys.Date()-92+2 i.e if subtracting gives me a weekend I need the next work day. I used the below. ifelse(weekdays(seq(seq(tf[[i]][j,1],by="-1 day",length.out=90)[90])=="Saturday",match(seq(tf[[i]][j,1],by="-1 day",length.out=90)[90]+2,tf[[i]][,1]),ifelse(weekdays(seq(tf[[i]][j,1], by="-1 day",length.out=90)[90])=="Sunday",match(seq(tf[[i]][j,1],by="-1 day",length.out=90)[90]+1,tf[[i]][,1]),match(seq(tf[[i]][j, 1],by="-1 day",length.out=90)[90],tf[[i]][,1]))) I would be grateful If anybody can help me with a more elegant/efficient approach. Thank you in advance for your time! Ravi This e-mail may contain confidential and/or privileged i...{{dropped:13}} ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.