search for: mes1

Displaying 2 results from an estimated 2 matches for "mes1".

Did you mean: mes
2006 Apr 17
1
Function for computing the difference between 2 dates in months
Folks: With the help of David L. Reiner, I've developed a function that computes the number of months between 2 dates, x and y. num.months <- function ( x , y ) { x <- as.Date( x ) y <- as.Date( y ) seeq <- seq(from=x , to=y , by="months") ans <- length( seeq ) - 1 if ( max( seeq) > y ) ans <- ans -1 ans } To ease your reading this function, I've
2006 Apr 19
0
Function for computing the difference between 2 dates inmonths
...ubstring(ie[,],255,256),substring(ie[,] ,253,254),sep="-")) Your functions works well only in example #1 but when I applied a "cycle" (if clause) doesn't work (example #2 and #3). Example #1: a35641<-num.months (dados$date1[35641],dados$date2[35641]) [1] 68 Example #2: mes1<-with(dados,ifelse(date1!=" - - ",num.months(date1,date2),"")) >Error in fromchar(x) : character string is not in a standard unambiguous format Example #3: mes<-c(rep("NA",length(dados$date1))) for (i in 1:m){ if (dados$date1[i]!=" - - &quo...