[R] leap year and order function

Bobby Lee
Mon, 31 Jan 2011 04:23:08 -0000

im trying to write a for loop so that every leap year, the number of days
becomes to 366 instead of 365. could someone help me out?
and also, this set of data has 99.99s I set all the 99.99 ==NA.
however, when im doing the order function to find the max value of that
year, it still reads 99.99 as the max value.
Thank you very much

maxday <- matrix(NA,63,5)

for (a in 1948:2010){

maxday[,1]<-1948:2010
yearly<-na.omit(dat.mat[dat.mat[,1]==a,])

maxday[a-1947,2]<-yearly[order(yearly[,4])[*365*],2]
maxday[a-1947,3]<-yearly[order(yearly[,4])[*365*],3]


maxday[63,2]<-yearly[order(yearly[,4])[127],2]
maxday[63,3]<-yearly[order(yearly[,4])[127],3]
maxday[a-1947,4]<-max(yearly[,4])
maxday[,5]<-len[,2]
}

	[[alternative HTML version deleted]]