Bin/categorise p values in R [duplicate]

We can use case_when to do a custom category

library(dplyr)
f1 <- function(pval) {
       case_when(pval > 0.5 ~ 'ns',
                 pval < 1e-4 ~ '4',
                 pval < 1e-3 ~ '3',
                 pval < 1e-2 ~ '2',
                 pval < 0.05 ~ '1'
                
                
                 )
      }


f1(c(0.04, 1.2,  0.00005))
#[1] "1"  "ns" "4"            

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top