Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. df <- data.frame(t1 = c(10, 20, 30, 1, 0), t2 = c(30, 0, 40, 0, 0), t3 = c(10, 0, 3, 10, 0))
  2.  
  3. df<- df%>% rowwise() %>%
  4. do({
  5. th <- c(.$t1, .$t2, .$t3,)
  6.  
  7.  
  8. data.frame(., t_s_last = min(th[th > 0))
  9. })
  10.  
  11. 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