Re: [R] Lowest year among several variables

2012-05-08 Thread Petr Savicky
On Tue, May 08, 2012 at 02:50:47PM -0500, Jeff wrote: > > ...still new to R and trying to figure this one out. > > I have a number of variables x, y, z, etc. in a data frame. > > Each contains a 2 digit year (e.g., 80, 81, 82) representing the > first year that something occurred. Each variable

Re: [R] Lowest year among several variables

2012-05-08 Thread Sarah Goslee
It's neater if you use dput() to give your data rather than just copying it into the email, but anyway: > testdata <- read.table("clipboard", header=TRUE) > apply(testdata, 1, function(x)if(all(x == 0)) {0} else {min(x[x > 0])}) [1] 80 76 86 0 Sarah On Tue, May 8, 2012 at 3:50 PM, Jeff wrote:

[R] Lowest year among several variables

2012-05-08 Thread Jeff
...still new to R and trying to figure this one out. I have a number of variables x, y, z, etc. in a data frame. Each contains a 2 digit year (e.g., 80, 81, 82) representing the first year that something occurred. Each variable represents a different type of event. If the event did not occu