I'm a beginner in R and I am stuck with the following..
df <- tibble( id = c(01, 02), a = c(0.44, 0.42), b = c(1, 0.42), c = c(NaN, 0.71), d = c(0.75, 0), e = c(0.66, 0.75), f = c(0.5, 0.22), g = c(1, NaN), h = c(0.8, NaN) ) I wonder how I can mutate a column that counts the number of cases of cells >0 - separately for the columns a:d and e:h (&rowwise)
I have been thinking of something like this..
df1 <- df %>% rowwise() %>% mutate(casesatod = length(which(., > 0), na.rm = TRUE), casesetoh = length(which(., > 0), na.rm = TRUE)) Of course, this code is not complete but to give you an idea of what I was thinking of..
I'd really looking forward to receiving help from you !
Thanks in advance !