0

I am trying to show in a forest plot which lines are statiscially significant after multiple testing correction. For that I have tried multiple ways to introduce a star mark in my y axis legend without success. My last try was to create a for loop with an ifelse condition inside to create a new vector (P_bis2) in my table (gen_cor0) that would add a star mark to the original vector (P_bis) when the p value (p) is below my threshold (9e-4):

for(i in 1:52) {
    if(gen_cor0$p<9e-4){
    gen_cor0$P_bis2<-paste0(gen_cor0$P_bis,"*")
    } else {
        gen_cor0$P_bis2<-paste0(gen_cor0$P_bis)
        }
}

Thank you very much for any help you can give

jo_henry
  • 1
  • 2
  • 1
    It is hard to understand you without a [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) minimal data set. But the first thing I can see in your codes, you use `i` inside the `for` but you never use it in your code block like `gen_cor0$P_bis[i]` , `gen_cor0$p[i]` and `gen_cor0$P_bis2[i]` etc. – maydin Jan 03 '22 at 14:51
  • That is my problem, I don't understand how to use it – jo_henry Jan 03 '22 at 15:01
  • 1
    By the way, you don't need a loop : `gen_cor0$P_bis2 <- ifelse(gen_cor0$p<9e-4, paste0(gen_cor0$P_bis,"*"), gen_cor0$P_bis)` – maydin Jan 03 '22 at 15:01

0 Answers0