Skip to content

possible bug in the grep #689

@elicegui

Description

@elicegui
  • in the function ggforest there is the expression
    vars = grep(paste0("^", var, "*."), coef$term, value = TRUE)
    data.frame(var = vars, Var1 = "", Freq = nrow(data),
    pos = seq_along(vars))

  • with a model like this
    coxph(formula = as.formula(sprintf("Surv(OS, OS_Status) ~ %s",
    paste(c("add11", "minus18", "add17", "del7q"), collapse = "+"))),
    data = data)

     coef exp(coef) se(coef)    z     p
     add11TRUE    0.8       2.1      0.5  1.6 0.107 
     minus18TRUE -0.3       0.7      0.5 -0.7 0.503
     add17TRUE    0.3       1.3      0.5  0.5 0.589
     del7qTRUE    1.1       3.1      0.4  3.0 0.003
    

The expression grep(paste0("^", var, "*."), coef$term, value = TRUE) ~
is equivalent for the first term to:
grep("^add11*.", coef$term, value=T)
[1] "add11TRUE" "add17TRUE"

and we obtain two values and subsequently the graphic is not correct

maybe we can change by grep(paste0("^", var, "TRUE|^",var,"FALSE"), coef$term, value = TRUE) to obtain only the add11. This code only executes for boolean variables.

testing
var="add11"
grep(paste0("^", var, "TRUE|^",var,"FALSE"), c("add11TRUE","add17TRUE"), value=T)
[1] "add11TRUE"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions