Hi, I do not know what part of my code should I post here (I use large size of data, the loop "for" contains many lines). The situation is difficult to post here, but I hope these lines would be useful for help:
hcEndDateTmp = userDateStart if((hcStartTime<="23:59") & (hcEndTime >= "00:00")){ hcEndDateTmp$mday = userDateStart$mday + 1 } hcEndDate = strftime(hcEndDateTmp, "%Y-%m-%d") hcStart = "" hcEnd = as.POSIXlt(paste(hcEndDate, hcEndTime)) for(rowNum in 1:nbJour){ ... hcStart = as.POSIXlt(ecs$startAt[[rowNum]]) ecsInterval2 = datePower[(datePower$DateTime>=hcStart)&(datePower$DateTime<=hcEnd), ] ... hcEnd$mday = hcEnd$mday + 1 cat("DEBUG: rowNum=", rowNum, "is.na(hcEnd)=", is.na(hcEnd), "\n") } the two last lines are very important. It yields: DEBUG: rowNum= 1 is.na(hcEnd)= FALSE DEBUG: rowNum= 2 is.na(hcEnd)= FALSE DEBUG: rowNum= 3 is.na(hcEnd)= FALSE DEBUG: rowNum= 4 is.na(hcEnd)= FALSE DEBUG: rowNum= 5 is.na(hcEnd)= FALSE DEBUG: rowNum= 6 is.na(hcEnd)= FALSE DEBUG: rowNum= 7 is.na(hcEnd)= TRUE Browse[1]> hcEnd [1] "2009-03-29 06:30:00" Browse[1]> class(hcEnd) [1] "POSIXlt" "POSIXt" So, At the end of 7th iteration, hcEnd becomes NA (I guess because of hcEnd$mday = hcEnd$mday + 1 ?!?). But It remains strange because the class of hcEnd is here "POSIXlt" "POSIXt" (it should be "logical".!! Am I wrong???) Here is the version of R: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 13.2 year 2011 month 09 day 30 svn rev 57111 language R version.string R version 2.13.2 (2011-09-30) thanks for your help -- View this message in context: http://r.789695.n4.nabble.com/strange-behaviour-of-POSIXlt-POSIXt-object-tp4418115p4424214.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.