I want to create a function to return the type of n-value (which is n-value is the 6 column of a dataframe) by using the following rules:
# n-value types
missing : NA
n > 0.05 : 'n.s.'
0.05 >= n > 0.01 : '*'
0.01 >= n > 0.001 : '**'
0.001 >= n > 0.0001 : '***'
0.0001 >= n : '****'
The first row of the data looks like:
n.name bMean log2FoldChange lfcSE stat pn padj
<fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
469 TNFRSF1B 542.82545 -3.406411 0.2267235 -15.024517 5.07e-51 3.25e-48
I tried the following:
c.1 <- function(n.1) {
p<- if (n.1>0.05)
return(p, paste0("n.s."))}
else{if (0.05 >= p > 0.01) return(p, paste0"'*'")
}
else{if (0.01 >= p > 0.001) return(p, paste0"'**'")
}
else{if (0.001 >= p > 0.0001) return(p, paste0"'***'")
}
else{if (0.0001 >= p) return(p, paste0"'****'")
}
else{cat(paste0("NA"))}
}
pType<-lapply(df.1$pn, c.1)
pType