[R] how do i find the annual maximun within several years?
    Doerte Salecker 
    doerte.salecker at uni-rostock.de
       
    Fri Oct 26 20:21:12 CEST 2007
    
    
  
dear kind helper,
i would like to know how to find the annual maximun for a table that
basicly looks like this:
date		time		measurement1	measurement2	measurement3
mm/dd/yyyy	hh:mm:ss	m1		m2		m3
there are about 9000 measurements for each year, which makes it quite
large...
i already tried to subset all rows for a year, to find the maximum
within these choosen rows,
y <- grep(yyyy,table[,1],value=TRUE)
df <-table[with(table, date == y), ]
df[with(df, max(measurement1)), ]
which got result some years, but didn't show all rows within these
years, and for other years it didn't work at all, 
     V1   V2 V3 V4 V5
NA <NA> <NA> NA NA NA
or/and gave warnings like: 
Warning messages:
1: longer object length
        is not a multiple of shorter object length in: is.na(e1) | is.na(e2)
2: longer object length
        is not a multiple of shorter object length in:
`==.default`(date, y) 
i also tried: 
result <- matrix(nrow=0,ncol=2)
for (y in yyyy:yyyy) {
  Y <- grep(y, table[,1],value=TRUE)
  Max <- max (subset(table, date %in% Y, c(date, measurement1))[,2])
  result2 <- (c(y,Max))
  result <- rbind(result2,result)
}
print(result)
that kind of worked, but only gave me the year in the result, but i need
the full date, for the statistical analysis. 
i hope you can help me with this,
thank you in advance,
d.salecker
    
    
More information about the R-help
mailing list