My df is like this
df <- data.frame(t1 = c(10, 20, 30, 1, 0), t2 = c(30, 0, 40, 0, 0), t3 = c(10, 0, 3, 10, 0))
what i want to do is find min in df line but not 0 I do
df<- df%>% rowwise() %>% do({ th <- c(.$t1, .$t2, .$t3,) data.frame(., t_s_last = min(th[th > 0)) })
but it works, but not for lines containing sth greater than 0. how to do this by returning 0 if there is only 0 in the line (line 5) ??
source share