[R] apply min function rowwise

From: moleps <moleps2_at_gmail.com>
Date: Sat, 05 Jun 2010 17:30:31 +0200


Im 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).

Ive 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



R-help_at_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. Received on Sat 05 Jun 2010 - 16:23:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 05 Jun 2010 - 17:00:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive