error in while loop

Hi All,

I am receiving an error while running a while loop. can you please help me out.

Code:

while((finalDate-auxDate)!=0){
	if(format(auxDate, format = "%d")=="01"){
		auxDate <- auxDate+15
	}else{
		auxDate <- auxDate-15
		month(auxDate) <- month(auxDate) + 1}
	if(!(auxDate %in% FCL_forecast[,7])){
		missingRows <- c(missingRows, auxDate)}
}
as.Date(missingRows) 

i am getting an error as :

Error in month(auxDate) <- month(auxDate) + 1 :
could not find function "month<-"

Thank you for the help and i am new, please let me know how can i explain this better

Regards,

Sachin

Take a look at the month() function in the lubridate package. There is also a day function that could be useful.

perfect it worked thanks

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.