1

I am new to R language and I am trying to understand what the !! operator is doing here

df %>% if (stringr::str_length("column")>0) dplyr::filter(., !!rlang::parse_expr(expr)) else .}
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
sainiamaan
  • 51
  • 1
  • 6
  • 3
    It is bang-bang operation. If you check the documentation,, help("!!")` gives more info – akrun Nov 04 '21 at 17:39
  • 3
    Please read the information at the top of the [tag:r] tag page and, in particular, provide complete reproducible code with all inputs and library statements. also code should be indented 4 spaces in which case SO will format it for you. – G. Grothendieck Nov 04 '21 at 17:44
  • Does this answer your question? [Use dynamic variable names in \`dplyr\`](https://stackoverflow.com/questions/26003574/use-dynamic-variable-names-in-dplyr) – NelsonGon Nov 04 '21 at 17:50
  • See https://stackoverflow.com/a/43419232/10323798 – NelsonGon Nov 04 '21 at 17:51
  • 1
    See the official rlang documentation: https://rlang.r-lib.org/reference/topic-inject.html – MrFlick Nov 04 '21 at 17:56

1 Answers1

1

Its a bang-bang operator used to force early evaluation of part of an expression before it gets fully evaluated. So, its forcing to evaluate that part of the expression before the rest.

With more input, I could provide a more detailed answer.

Spartacus Rocha
  • 546
  • 1
  • 6
  • 14