I'm struggling to group values of multiple columns in different categories, i.e. I want to count the number of rows with values > x for multiple columns. In Excel I would use the COUNTIF function but I'm not sure how to do that in R.
For one column I would use
sum(df[,1]<=0.05) or length(which(df[,1]<= 0.05))
For multiple columns (column 2 to 25) like this but that's not working...
count <- df %>% dplyr::summarise(across(2:25, sum(.<= 0.05))))
What am I doing wrong?
Can you help me with an alternative for that using dplyr? And maybe also an option to count based on multiple conditions in one step? So for example all values <= 0.05 in one row and all values >= 0.05 & < 0.1 in the next row and so on?