[R] apply min function rowwise

moleps moleps2 at gmail.com
Sat Jun 5 17:30:31 CEST 2010


I´m trying to tease out the minimum value from a row in a dataframe where all the variables are dates. 

apply(canc[,vec],1,function(x)min(x,na.rm=T))


However it only returns empty strings for the entire dataframe except for one date value (which is not the minimum date).

I´ve also tried 

apply(canc[,vec],1,function(x)max(x,na.rm=T))

which provides values rowwise, but many of them are not in fact the largest in the row.


Any advice?


Regards,

//M



More information about the R-help mailing list