Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df <- data.frame(t1 = c(10, 20, 30, 1, 0), t2 = c(30, 0, 40, 0, 0), t3 = c(10, 0, 3, 10, 0))
- df<- df%>% rowwise() %>%
- do({
- th <- c(.$t1, .$t2, .$t3,)
- data.frame(., t_s_last = min(th[th > 0))
- })
- apply(df, 1, function(x) if(all(x==0)) 0 else min(x[x> 0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement